-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GeoJSON does not write urn:ogc:def:crs:OGC::CRS84 #2035
Comments
I see your point(s), but I'm not sure we want to change things in that area. Format conversion is not intended to be always round-trippable, and the last GeoJSON version RFC7946 (available as a creation option) removes any explicit support for CRS in GeoJSON. |
But that only happens (returning the EPSG:4326) if there is no CRS information in the geojson file. |
True indeed. Missed that. Comes from the fact that GDAL has a historic hardcoded WKT representation for urn:ogc:def:crs:OGC:1.3:CRS84 that is the same as EPSG:4326 but doesn't include the EPSG:4326 authority and use longitude, latitude axis order (on purpose). That said, this is historic behaviour, and with PROJ 6 we have now a OGC:CRS84 entry in proj.db, so if we removed that hardcoded string from SetFromUserInput() implementation, we'd got a WKT representation with a OGC:CRS84 authority. Which wouldn't probably be ideal for the sake of doing later coordinate transformations, as mixing CRS from different authorities will lead to suboptimal datum transformation propositions.
Mostly comes from the fact that the old GeoJSON 2008 spec recommended using urn:ogc:def:crs:OGC:1.3:CRS84 over EPSG:4326: https://geojson.org/geojson-spec#named-crs Writing EPSG:4326 in the GeoJSN file could lead to ambiguities about the ordering of coordinates in the GeoJSON file. All in all, a mix of format specificities, historic behaviour, data axis order mess... As there's no major functional disorder due to current behaviour (like wrong axis order), the benefit vs risk ratio of changing current behaviour is a bit low :-) What could perhaps be done is on the writing side to write "urn:ogc:def:crs:OGC::CRS84" in the GeoJSON file if the input CRS was "urn:ogc:def:crs:OGC::CRS84", but I'd suggest rather not to use "urn:ogc:def:crs:OGC::CRS84" for CRS passed to CreateLayer(). With other formats, it could cause issues that you wouldn't have if you would use plain EPSG:4326 |
Thanks for the explanation! I fully agree that given the current (historic) "mess", changing something might only increase the mess ;) But, from an application standpoint, like GeoPandas, I was thinking if we should automatically convert CRS84 into EPSG:4326 on reading the file (if the file source is geojson). |
…:1.3:CRS84, report EPSG:4326 as we used to do in GDAL 2 (refs #2035)
…:1.3:CRS84, report EPSG:4326 as we used to do in GDAL 2 (refs #2035)
That does make sense. Actually I missed there was a difference in behaviour between GDAL 3 and GDAL 2 when the GeoJSON file had a crs: urn:ogc:def:crs:OGC:1.3:CRS84. GDAL 2 used to report EPSG:4326, whereas currently GDAL does not. GDAL 2 behaviour seems preferable, so I've just fixed that per cd9e06c and backported it to 3.0 branch. So with that fix, a workaround on GeoPandas/Fiona wouldn't be needed Note: my previous explanation about GDAL 2 not including EPSG:4326 authority in its urn:ogc:def:crs:OGC:1.3:CRS84 hardcoded WKT was wrong ! It actually did included it (but omitted explicit axis order, which meant implicitly long, lat). This is something I've changed in GDAL 3 (not to lie on the authority and adding explicit long, lat order), but this had this side effect on the GeoJSON driver. Pfff :-) |
Thanks @rouault! |
Thanks a lot on the quick follow-up @rouault ! |
Expected behavior and actual behavior.
With the GeoJSON driver and GDAL 3.0.2, when writing
EPSG:4326
to the file, it writesurn:ogc:def:crs:OGC::CRS84
and returnsurn:ogc:def:crs:OGC::CRS84
. However, when you writeurn:ogc:def:crs:OGC::CRS84
to the file, it does not write the CRS and returnsEPSG:4326
.It would be nice if there was consistency such that the roundtrip writing/reading of the CRS preserved the original CRS. But, if there is a reason for the behavior, that would be good to know as well. Thanks!
Steps to reproduce the problem.
Write EPSG:4326:
Write
urn:ogc:def:crs:OGC::CRS84
:Operating system
GDAL version and provenance
The text was updated successfully, but these errors were encountered: