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

Unexpected CRS inequality when roundtripped with WKT #3871

Closed
djhoese opened this issue Sep 1, 2023 · 0 comments
Closed

Unexpected CRS inequality when roundtripped with WKT #3871

djhoese opened this issue Sep 1, 2023 · 0 comments
Assignees
Labels

Comments

@djhoese
Copy link
Contributor

djhoese commented Sep 1, 2023

Example of problem

#include <proj.h>
#include <stdio.h>

int main(void) {
    PJ_CONTEXT* context = proj_context_create();
    PJ* pj1 = proj_create(
        context,
"PROJCRS[\"unknown\",BASEGEOGCRS[\"unknown\",DATUM[\"unknown\",ELLIPSOID[\"unknown\",6378137,298.257024882273,LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]]],PRIMEM[\"Greenwich\",0,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8901]]],CONVERSION[\"unknown\",METHOD[\"Geostationary Satellite (Sweep Y)\"],PARAMETER[\"Longitude of natural origin\",140.7,ANGLEUNIT[\"degree\",0.0174532925199433],ID[\"EPSG\",8802]],PARAMETER[\"Satellite Height\",35785863,LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]],PARAMETER[\"False easting\",0,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8806]],PARAMETER[\"False northing\",0,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8807]]],CS[Cartesian,2],AXIS[\"(E)\",east,ORDER[1],LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]],AXIS[\"(N)\",north,ORDER[2],LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]]]"
    );
    PJ* pj2 = proj_create(
        context,
"PROJCRS[\"unknown\",BASEGEOGCRS[\"GCS_unknown\",DATUM[\"D_unknown\",ELLIPSOID[\"unknown\",6378137,298.257024882273,LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]]],PRIMEM[\"Greenwich\",0,ANGLEUNIT[\"Degree\",0.0174532925199433]]],CONVERSION[\"unnamed\",METHOD[\"Geostationary Satellite (Sweep Y)\"],PARAMETER[\"Longitude of natural origin\",140.7,ANGLEUNIT[\"Degree\",0.0174532925199433],ID[\"EPSG\",8802]],PARAMETER[\"Satellite Height\",35785863,LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]],PARAMETER[\"False easting\",0,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8806]],PARAMETER[\"False northing\",0,LENGTHUNIT[\"metre\",1],ID[\"EPSG\",8807]]],CS[Cartesian,2],AXIS[\"easting\",east,ORDER[1],LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]],AXIS[\"northing\",north,ORDER[2],LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]]]"
    );
    printf("%d\n", proj_is_equivalent_to_with_ctx(
        context, pj1, pj2, PJ_COMP_EQUIVALENT
    ));
    return 0;
}

Problem description

I have a user of my Python-based software that wants to compare a CRS loaded from a PROJ.4 string to a CRS created from a geotiff created with that same CRS in WKT2. We use pyproj and rasterio to convert a pyproj CRS object to WKT2_2018, give it to rasterio (and therefore GDAL), and save it as a geotiff. The user then loads this geotiff with rasterio and converts the rasterio CRS to a pyproj CRS. When comparing the CRSes they are not considered equal but as far as we can tell the only difference is the coordinate operation. CC @snowman2 @simonrp84

Above is a comparison of the WKT2_2019 (note the difference in year from the WKT2 used in creating the geotiff) directly in PROJ. These strings were generated by my user from the pyproj CRS objects with crs.to_wkt(). As far as I can tell everything is the same except for "degree" versus "Degree" and "D_unknown" versus "unknown". pj1 is the original CRS loaded from a PROJ.4 string. pj2 is the CRS loaded from the geotiff.

This may be similar to #3725.

Expected Output

Get 0 (not equal), expect 1 (equal).

Environment Information

  • PROJ version (proj): 9.2.1 and 9.0.0
  • Operation System Information: Ubuntu

Installation method

  • conda, apt-get, from source, etc...

conda-forge

Edit: Sorry, I'm not good enough with the PROJ API to do the various WKT conversions to test the equivalent operations I did in Python.

@djhoese djhoese added the bug label Sep 1, 2023
@rouault rouault self-assigned this Sep 1, 2023
@rouault rouault closed this as completed in 8d52b30 Sep 2, 2023
rouault added a commit that referenced this issue Sep 2, 2023
ESRI WKT import: normalize GCS_unknown to unknown and D_unknown to unknown (fixes #3871)
rouault added a commit that referenced this issue Sep 3, 2023
[Backport 9.3] ESRI WKT import: normalize GCS_unknown to unknown and D_unknown to unknown (fixes #3871)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants