Closed trexfeathers closed 1 year ago
Thanks for any help you can give 😊
This is interesting:
>>> from pyproj import CRS
>>> crs_wkt = ' GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'
>>> CRS(crs_wkt)
<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
>>> CRS.from_wkt(crs_wkt)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../pyproj/pyproj/crs/crs.py", line 431, in from_wkt
raise CRSError(f"Invalid WKT string: {in_wkt_string}")
pyproj.exceptions.CRSError: Invalid WKT string: GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
>>> from pyproj.crs import is_wkt
>>> is_wkt(crs_wkt)
False
>>> is_wkt(crs_wkt.strip())
True
This issue will be addressed in the next PROJ release: https://github.com/OSGeo/PROJ/issues/3840
Brilliant, thanks so much @snowman2!
Thanks!
Hi all,
After upgrading to 3.6.1, we are still seeing the issue reported here https://github.com/ESMValGroup/ESMValTool/issues/3203.
This issue was solved in PROJ (9.3.0), not in pyproj. Which version of PROJ are you using/linking?
Sorry for the late reply. Still using 9.2.1, will have to update.
(Only reference to leading spaces I could find was not about WKT).
Code Sample, a copy-pastable example if possible
A WKT string with a leading space works with Proj directly (OSGeo/PROJ@93d8fccd51a704c4accd535743a963ad0ca5a274):
This same string does not work with PyProj:
But the string does work with PyProj if the leading space is removed:
Problem description
Consistency between Proj and PyProj is important for avoiding confusion about what WKT strings have valid formatting. We are aware of files where the WKT string is padded (SciTools/iris#5343), but it is now unclear whether this format is valid (according to Proj) or invalid (according to PyProj).
Expected Output
Environment Information
pyproj -v
Installation method
Conda
Conda environment information (if you installed with conda):
Environment (
conda list
):Details about
conda
and system (conda info
):