CRS comparison no longer equal with pyproj 3.2
See original GitHub issueCode Sample, a copy-pastable example if possible
A “Minimal, Complete and Verifiable Example” will make it much easier for maintainers to help you: http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports
from pyproj import CRS
proj_str = "+proj=omerc +lat_0=50 +alpha=50.0 +no_rot +a=6378144.0 +b=6356759.0 +lon_0=8.0"
crs = CRS.from_string(proj_str)
crs == CRS(crs.to_wkt())
# False
crs == CRS(crs.to_wkt("WKT1_GDAL"))
# True
Extra context:
crs.to_wkt()
# 'PROJCRS["unknown",BASEGEOGCRS["unknown",DATUM["unknown",ELLIPSOID["unknown",6378144,298.253168108487,LENGTHUNIT["metre",1,ID["EPSG",9001]]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],CONVERSION["unknown",METHOD["PROJ omerc no_rot"],PARAMETER["lat_0",50,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]],PARAMETER["alpha",50,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]],PARAMETER["lon_0",8,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]]],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]]],REMARK["PROJ CRS string: +proj=omerc +lat_0=50 +alpha=50.0 +no_rot +a=6378144.0 +b=6356759.0 +lon_0=8.0"]]'
CRS(crs.to_wkt()).to_wkt()
# 'PROJCRS["unknown",BASEGEOGCRS["unknown",DATUM["unknown",ELLIPSOID["unknown",6378144,298.253168108487,LENGTHUNIT["metre",1,ID["EPSG",9001]]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],CONVERSION["unknown",METHOD["PROJ omerc no_rot"],PARAMETER["lat_0",50,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]],PARAMETER["alpha",50,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]],PARAMETER["lon_0",8,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]]],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]]],REMARK["PROJ CRS string: +proj=omerc +lat_0=50 +alpha=50.0 +no_rot +a=6378144.0 +b=6356759.0 +lon_0=8.0"]]'
crs.to_wkt() == CRS(crs.to_wkt()).to_wkt()
# True
Problem description
In older versions of pyproj/PROJ this equality used to work fine. This conversion to/from WKT is something we do in pyresample to support older versions of pyproj where CRS/Proj objects were not thread-safe.
Expected Output
The two versions of the CRS are considered equal. I’m not sure the easiest way to find out why they are unequal since the WKT is the same.
Environment Information
- Output from:
pyproj -v
pyproj info:
pyproj: 3.2.1
PROJ: 8.1.1
data dir: /home/davidh/miniconda3/envs/satpy_py39/share/proj
user_data_dir: /home/davidh/.local/share/proj
System:
python: 3.9.7 | packaged by conda-forge | (default, Sep 14 2021, 01:17:55) [GCC 9.4.0]
executable: /home/davidh/miniconda3/envs/satpy_py39/bin/python
machine: Linux-5.13.0-7614-generic-x86_64-with-glibc2.33
Python deps:
certifi: 2021.05.30
pip: 21.2.4
setuptools: 58.0.4
Cython: None
Installation method
- conda with conda-forge packages
Conda environment information (if you installed with conda):
Environment (
conda list
):
$ conda list proj
# packages in environment at /home/davidh/miniconda3/envs/satpy_py39:
#
# Name Version Build Channel
proj 8.1.1 h277dcde_2 conda-forge
pyproj 3.2.1 py39ha81a305_2 conda-forge
Details about
conda
and system ( conda info
):
$ conda info
Issue Analytics
- State:
- Created 2 years ago
- Comments:19 (19 by maintainers)
Top Results From Across the Web
Gotchas/FAQ - pyproj 3.4.0 documentation - GitHub Pages
The reason that the EPSG code does not appear with the CRS initialized with the init= syntax is that the CRS are different....
Read more >CRS classmethods changed to staticmethods #847 - GitHub
At some point pyproj used classmethods for constructor-type methods in pyproj.crs.CRS. In this commit this was changed to use staticmethods.
Read more >Transforming EPSG:4979 to given WKT (~EPSG:6654)
The problem is creating the transform via pyproj and maintaining projection complexity in 3D. My pyproj version is 3.2.1. Suppose the input WKT ......
Read more >Geopandas' "to_crs" function won't work with Orthographic ...
I am trying to use Geopandas to plot a map of the world in the Orthographic Projection, as shown in TowardsDataScience and tried...
Read more >pyproj - PyPI
Python interface to PROJ (cartographic projections and coordinate transformations library)
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
See https://github.com/OSGeo/PROJ/pull/2812 and https://github.com/OSGeo/PROJ/pull/2809
Ok new discovery, PROJ 8.1.1 seems to now include a “REMARK” in the WKT and it seems this effects comparison results. However, it is very touchy. For example, not only does the order of the dictionary parameters matter (since they python dicts are ordered now), but also floats versus ints in the numeric parameters.