as part of a government driven Open Data project my city made some geodata accessible via Web Feature Service. A third party did convert some of this data to GeoJSON, so more people can use it. The data looks like that:
{
"type": "FeatureCollection",
"name": "Hauskoordinaten",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{
"type": "Feature",
"id": 5,
"properties": {
"objectid": "5",
"strschl": "1",
"adresse": "Aachener Str. *",
"strname": "Aachener Str.",
"x": "32359072.929",
"y": "5701476.297"
},
"geometry": {
"type": "Point",
"coordinates": [
6.971984166915553,
51.446915354002748
]
}
},
{ "type": "Feature", "id": 6, "properties": { "objectid": "6", "strschl": "1", "hsnr": "1", "adresse": "Aachener Str. 1", "strname": "Aachener Str.", "x": "32359252.047", "y": "5701464.014" }, "geometry": { "type": "Point", "coordinates": [ 6.974564923492866, 51.446849521064742 ] } },
{ "type": "Feature", "id": 7, "properties": { "objectid": "7", "strschl": "1", "hsnr": "2", "adresse": "Aachener Str. 2", "strname": "Aachener Str.", "x": "32359267.632", "y": "5701483.058" }, "geometry": { "type": "Point", "coordinates": [ 6.974781475486739, 51.447024527120796 ] } },
{ "type": "Feature", "id": 8, "properties": { "objectid": "8", "strschl": "1", "hsnr": "3", "adresse": "Aachener Str. 3", "strname": "Aachener Str.", "x": "32359236.486", "y": "5701463.429" }, "geometry": { "type": "Point", "coordinates": [ 6.974341375868697, 51.446840396580718 ] } },
{ "type": "Feature", "id": 9, "properties": { "objectid": "9", "strschl": "1", "hsnr": "4", "adresse": "Aachener Str. 4", "strname": "Aachener Str.", "x": "32359252.073", "y": "5701482.515" }, "geometry": { "type": "Point", "coordinates": [ 6.97455793901083, 51.447015780957109 ] } }
]
}
If I load this data into a random online GeoJSON visualizer, it appears just fine.
If I try to enter these coordinates into Google Maps, I have to swap their order: 6.97455793901083, 51.447015780957109
is some random point in the ocean, 51.447015780957109, 6.97455793901083
is what I want and what looks right.
As someone that doesn't really have a clue of cartography, geography, map projections and so one: Why is that? Is the data in a unusual format? Does GeoJSON for whatever reason require the "swapped" format? Or is Google Maps the one that falls out of the line?
CodePudding user response:
The ordering is different between GeoJSON and Google Maps.
There has long been disagreement (latitude/longitude vs. x/y). See Geotools::Axis Order for some history.
A position in GeoJSON is defined as:
3.1.1. Position
A position is an array of numbers. There MUST be two or more elements. The first two elements are longitude and latitude, or easting and northing, precisely in that order and using decimal numbers.
Google Maps (where not specified by name or object specification) uses the order latitude, longitude.
from: Google Maps Help: Discover coordinates or search by latitude & longitude
Format your coordinates
To format your coordinates so they work in Google Maps, use decimal degrees in the following format:
Correct: 41.40338, 2.17403
Incorrect: 41,40338, 2,17403
Tips:
List your latitude coordinates before longitude coordinates. (emphasis mine)