CRS Axis Order issues with 1.8.9
See original GitHub issueProblem Description
When reading in: https://raw.githubusercontent.com/geopandas/geopandas/master/geopandas/tests/data/overlay/overlap/df1_df2_overlap-union.geojson
With previous versions of Fiona, the WKT string was read in as:
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]
However, currently (1.8.9) it is read in as:
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Longitude",EAST],AXIS["Latitude",NORTH]]
Everything is mostly the same except for the axis order at the end.
I believe this is due to this line: https://github.com/Toblerity/Fiona/blob/960568d2fede452a042e5c9f315fb93e3cd56baa/fiona/_crs.pyx#L65
This is problematic for a couple of reasons:
- It does not preserve the original WKT string/projection and mangles it
- What if the user actually modified their data to be in the axis order mentioned in the WKT string? How would they tell Fiona that they did so?
Recommended Solution
Add an always_xy
flag to crs_to_wkt()
and only use it when creating a CRS to be used in the transformation. It would also be a good idea to add an always_xy
flag to the transformation operations for the case where the user modified the underlying data to match the axis order specified in the CRS. For Fiona 1.8.x, the always_xy
flag could be omitted from the transformation operations and just default to always_xy=True
in crs_to_wkt()
Thoughts?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:27 (27 by maintainers)
Top GitHub Comments
Not a problem! Looks like EPSG:4326 is the winner in this scenario and the fix is in GDAL, so no change needed in Fiona.
Well, Fiona (or GDAL) does go against it. When you use
RFC7946="YES"
, you actually get back EPSG:4326 … It’s only when not using the new spec that you get back CRS84 (well, you get back what is written into the “crs” field of the geojson file, but it is impossible to write EPSG:4326 in that field, as it always get converted to CRS84)