Skip to content
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

WKT1 format for CRS84 from GDAL results in EPSG:4326 with lon/lat axis order #475

Closed
jorisvandenbossche opened this issue Nov 6, 2019 · 5 comments
Labels
proj Bug or issue related to PROJ

Comments

@jorisvandenbossche
Copy link
Contributor

From Toblerity/Fiona#816 (comment), I noticed that the WKT that was produced by Fiona / GDAL for the "urn:ogc:def:crs:OGC:1.3:CRS84" has a strange behaviour when read in pyproj:

In [11]: crs = pyproj.CRS('GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]')                                     

In [12]: crs                                                                                                                                                                                                       
Out[12]: 
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- lon[east]: Longitude (Degree)
- lat[north]: Latitude (Degree)
Area of Use:
- undefined
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich

In [13]: crs.to_authority()                                                                                                                                                                                        
Out[13]: ('EPSG', '4326')

So you can see that the axis order is correct I think (lon, lat), as this is coming from CRS84 (which should be EPSG:4326 but with swapped axis). But it still directly recognizes this as EPSG:4326 (it's even in the first line of the repr).
Which seemingly gives a CRS that contradicts itself? (this probably is a behaviour defined by PROJ though)


In [16]: pyproj.show_versions()   
pyproj info:
    pyproj: 2.4.0
      PROJ: 6.2.0
  data dir: /home/joris/miniconda3/envs/test-fiona-189/share/proj

System:
    python: 3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 21:52:21)  [GCC 7.3.0]
executable: /home/joris/miniconda3/envs/test-fiona-189/bin/python
   machine: Linux-4.15.0-1059-oem-x86_64-with-debian-buster-sid

Python deps:
       pip: 19.3.1
setuptools: 41.6.0.post20191101
    Cython: None
@snowman2
Copy link
Member

snowman2 commented Nov 6, 2019

Interesting.

this probably is a behaviour defined by PROJ though

Yes, that is the case. Probably need to raise this issue upstream.

@snowman2 snowman2 added proj Bug or issue related to PROJ and removed bug labels Nov 6, 2019
@jorisvandenbossche
Copy link
Contributor Author

cc @rouault

@rouault
Copy link

rouault commented Nov 6, 2019

Yes, this is a fuzzy area... "GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]" is the canonical representation of EPSG:4326 in ESRI WKT. So identification to it is OK. For some reason I don't really remember, I preferred that on import of such a WKT without an explicit axis order, we use traditional axis order "long", "lat". Not really sure what would be the impact of changing this

@jorisvandenbossche
Copy link
Contributor Author

I think what I find most unexpected (without knowing the background you just sketched) is that it gives EPSG:4326 with full confidence, while the axis order does not match:

In [73]: crs.to_authority(min_confidence=100)  
Out[73]: ('EPSG', '4326')

While for a similar object (reconstructed by roundtripping to WKT2), needs a min_confidence of 20 to ignore the axis order to return EPSG:4326:

In [74]: crs2 = pyproj.CRS(crs.to_wkt()) 

In [75]: crs2.to_authority(min_confidence=100) 

In [76]: crs2.to_authority(min_confidence=70)
Out[76]: ('OGC', 'CRS84')

In [77]: crs2.to_epsg(min_confidence=20)   
Out[77]: 4326

@jorisvandenbossche
Copy link
Contributor Author

But thanks for the explanation of the context!

In any case, it's thus not a pyproj issue, so closing here.

rouault added a commit to rouault/PROJ that referenced this issue Nov 9, 2019
Or more generally formulations that don't have an explicit axis order.
Refs pyproj4/pyproj#475

projinfo 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]'
returns EPSG:4326 with 100% confidence.
But its axis order is not the same as EPSG:4326.

I've pondered about this, like decreasing the confidence of the match,
but this would have downstream effects on GDAL (shapefiles with the
above content in a .prj would no longer be identified as EPSG:4326).
So for now, document that oddity.
backporting bot pushed a commit to OSGeo/PROJ that referenced this issue Nov 11, 2019
Or more generally formulations that don't have an explicit axis order.
Refs pyproj4/pyproj#475

projinfo 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]'
returns EPSG:4326 with 100% confidence.
But its axis order is not the same as EPSG:4326.

I've pondered about this, like decreasing the confidence of the match,
but this would have downstream effects on GDAL (shapefiles with the
above content in a .prj would no longer be identified as EPSG:4326).
So for now, document that oddity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proj Bug or issue related to PROJ
Projects
None yet
Development

No branches or pull requests

3 participants