question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bound CRS does not roundtrip through WKT

See original GitHub issue

Code Sample, a copy-pastable example if possible

Using the Bound CRS example from the geopandas docs:

>>> import pyproj
>>> crs = pyproj.CRS("+proj=lcc +lat_1=51.16666723333333 +lat_2=49.8333339 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1 +units=m +no_defs")
>>> crs.to_wkt()
'BOUNDCRS[SOURCECRS[PROJCRS["unknown",BASEGEOGCRS["unknown",DATUM["Unknown based on International 1909 (Hayford) ellipsoid",ELLIPSOID["International 1909 (Hayford)",6378388,297,LENGTHUNIT["metre",1,ID["EPSG",9001]]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],CONVERSION["unknown",METHOD["Lambert Conic Conformal (2SP)",ID["EPSG",9802]],PARAMETER["Latitude of false origin",90,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8821]],PARAMETER["Longitude of false origin",4.36748666666667,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8822]],PARAMETER["Latitude of 1st standard parallel",51.1666672333333,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8823]],PARAMETER["Latitude of 2nd standard parallel",49.8333339,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8824]],PARAMETER["Easting at false origin",150000.013,LENGTHUNIT["metre",1],ID["EPSG",8826]],PARAMETER["Northing at false origin",5400088.438,LENGTHUNIT["metre",1],ID["EPSG",8827]]],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]]]]],TARGETCRS[GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["latitude",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["longitude",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]]],ABRIDGEDTRANSFORMATION["Transformation from unknown to WGS84",METHOD["Position Vector transformation (geog2D domain)",ID["EPSG",9606]],PARAMETER["X-axis translation",106.869,ID["EPSG",8605]],PARAMETER["Y-axis translation",-52.2978,ID["EPSG",8606]],PARAMETER["Z-axis translation",103.724,ID["EPSG",8607]],PARAMETER["X-axis rotation",-0.33657,ID["EPSG",8608]],PARAMETER["Y-axis rotation",0.456955,ID["EPSG",8609]],PARAMETER["Z-axis rotation",-1.84218,ID["EPSG",8610]],PARAMETER["Scale difference",1.000001,ID["EPSG",8611]]]]'

Converting through WKT does not return the original CRS:

>>> crs2 = pyproj.CRS(crs.to_wkt())
>>> crs2 == crs
False
>>> crs.to_wkt() == crs2.to_wkt()
False
>>> crs2.to_wkt()
'BOUNDCRS[SOURCECRS[PROJCRS["unknown",BASEGEOGCRS["unknown",DATUM["Unknown based on International 1909 (Hayford) ellipsoid",ELLIPSOID["International 1909 (Hayford)",6378388,297,LENGTHUNIT["metre",1,ID["EPSG",9001]]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],CONVERSION["unknown",METHOD["Lambert Conic Conformal (2SP)",ID["EPSG",9802]],PARAMETER["Latitude of false origin",90,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8821]],PARAMETER["Longitude of false origin",4.36748666666667,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8822]],PARAMETER["Latitude of 1st standard parallel",51.1666672333333,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8823]],PARAMETER["Latitude of 2nd standard parallel",49.8333339,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8824]],PARAMETER["Easting at false origin",150000.013,LENGTHUNIT["metre",1],ID["EPSG",8826]],PARAMETER["Northing at false origin",5400088.438,LENGTHUNIT["metre",1],ID["EPSG",8827]]],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]]]]],TARGETCRS[GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]]],ABRIDGEDTRANSFORMATION["Transformation from unknown to WGS84",METHOD["Position Vector transformation (geog2D domain)",ID["EPSG",9606]],PARAMETER["X-axis translation",106.869,ID["EPSG",8605]],PARAMETER["Y-axis translation",-52.2978,ID["EPSG",8606]],PARAMETER["Z-axis translation",103.724,ID["EPSG",8607]],PARAMETER["X-axis rotation",-0.33657,ID["EPSG",8608]],PARAMETER["Y-axis rotation",0.456955,ID["EPSG",8609]],PARAMETER["Z-axis rotation",-1.84218,ID["EPSG",8610]],PARAMETER["Scale difference",1.000001,ID["EPSG",8611]]]]'

The WKT derived from each is a bit different:

>>> len(crs.to_wkt())
2020
>>> len(crs2.to_wkt())
2050

Expected Output

Bound CRS information should roundtrip through WKT, right? I didn’t see anything in the docs to suggest that this should be lossy.

Environment Information

pyproj info:
    pyproj: 2.6.0
      PROJ: 6.3.1
  data dir: /Users/bcward/opt/miniconda3/envs/geopandas/lib/python3.8/site-packages/pyproj-2.6.0-py3.8-macosx-10.9-x86_64.egg/pyproj/proj_dir/share/proj

System:
    python: 3.8.2 (default, Mar 26 2020, 10:43:30)  [Clang 4.0.1 (tags/RELEASE_401/final)]
executable: /Users/bcward/opt/miniconda3/envs/geopandas/bin/python
   machine: macOS-10.15.3-x86_64-i386-64bit

Installation method

conda

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
brendan-wardcommented, Apr 14, 2020

Thanks for investigating @snowman2 !

0reactions
snowman2commented, Apr 14, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can we construct WKT2 from PROJ4String correctly?
I saved the WKT into a text file "wkt2.prj" and had a try with ... The roundtrip is perfect so the WKT2 version...
Read more >
Migration to PROJ6/GDAL3
PROJ strings to encode CRS should be considered as a a legacy solution. Using a AUTHORITY:CODE or WKT representation is the recommended way....
Read more >
Functions — PROJ 9.1.1 documentation
In particular geographic CRS are assumed to have axis in the longitude, latitude order and with degree angular unit. If there is no...
Read more >
CRS - pyproj 3.5.0.dev0 documentation - GitHub Pages
Retrieves all relevant axis information in the CRS. If it is a Bound CRS, it gets the axis list from the Source CRS....
Read more >
Understand EPSG, WKT and Other CRS Definition Styles
Note that there are no specified units above. This is because this geographic coordinate reference system is in latitude and longitude which is ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found