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

Upgrade from 1.9.6 to 2.0.1 causes pyproj.exceptions.ProjError: Error creating CRS to CRS #191

Closed
KAMI911 opened this issue Mar 13, 2019 · 16 comments
Labels
bug proj Bug or issue related to PROJ
Milestone

Comments

@KAMI911
Copy link

KAMI911 commented Mar 13, 2019

I mainly using and testing pyproj under Linux /Ubuntu 18.04 64 bit/ and Travis CI environment.

While I upgraded to latest 2.0.1 version from 1.9.6 version I hit into this problem:
https://travis-ci.org/KAMI911/lactransformer/jobs/505569736

ERROR: test_las_transformation_las_to_EOV2009 (main.TestLasTransformation_from_WGS84geo)

Traceback (most recent call last):
File "test_lactransformer.py", line 388, in test_las_transformation_las_to_EOV2009
self.las_data.TransformPointCloud()
File "/home/travis/build/KAMI911/lactransformer/lactransformer/libs/LasPyConverter.py", line 133, in TransformPointCloud
self.__DestinationOpenedFile.x, self.__DestinationOpenedFile.y, self.__DestinationOpenedFile.z = transform(self.__SourceProj, self.__DestinationProj, self.__SourceOpenedFile.x, self.__SourceOpenedFile.y, self.__SourceOpenedFile.z)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/pyproj/init.py", line 507, in transform
_proj._transform(p1, p2, inx, iny, inz)
File "pyproj/_proj.pyx", line 302, in pyproj._proj._transform
File "pyproj/_proj.pyx", line 276, in pyproj._proj.TransProj.init
pyproj.exceptions.ProjError: Error creating CRS to CRS.

When I switch back to 1.9.6 the problems are gone:
https://travis-ci.org/KAMI911/lactransformer/jobs/505579144

Some printings that may help:

(pyproj.Proj('+proj=geocent +ellps=WGS84 +datum=WGS84 +units=m +no_defs ', preserve_units=True), pyproj.Proj('+proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +nadgrids=/home/travis/build/KAMI911/lactransformer/lactransformer/grid/etrs2eov_notowgs.gsb +geoidgrids=/home/travis/build/KAMI911/lactransformer/lactransformer/grid/geoid_eht.gtx +units=m +no_defs ', preserve_units=True), array([4072352.038, 4072350.845, 4072352.694, ..., 4071665.054,
4071689.017, 4071695.836]), array([1406781.664, 1406783.521, 1406781.519, ..., 1407165.48 ,
1407119.194, 1407133.864]), array([4687388.295, 4687382.027, 4687385.287, ..., 4687839.668,
4687832.19 , 4687823.562]))
(pyproj.Proj('+proj=geocent +ellps=WGS84 +datum=WGS84 +units=m +no_defs ', preserve_units=True), pyproj.Proj('+proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +nadgrids=/home/travis/build/KAMI911/lactransformer/lactransformer/grid/etrs2eov_notowgs.gsb +geoidgrids=/home/travis/build/KAMI911/lactransformer/lactransformer/grid/geoid_eht2014.gtx +units=m +no_defs ', preserve_units=True), array([4072352.038, 4072350.845, 4072352.694, ..., 4071665.054,
4071689.017, 4071695.836]), array([1406781.664, 1406783.521, 1406781.519, ..., 1407165.48 ,
1407119.194, 1407133.864]), array([4687388.295, 4687382.027, 4687385.287, ..., 4687839.668,
4687832.19 , 4687823.562]))

My project's source:

https://github.com/KAMI911/lactransformer/tree/master/lactransformer

Converter class, where I hit to error:
https://github.com/KAMI911/lactransformer/blob/master/lactransformer/libs/LasPyConverter.py#L18

Maybe these Proj instance works differently?
self.__SourceProj = Proj(self.__SourceProjectionString)
self.__DestinationProj = Proj(self.__DestinationProjectionString)

and causes this exception:

Traceback (most recent call last):
File "test_lactransformer.py", line 388, in test_las_transformation_las_to_EOV2009
self.las_data.TransformPointCloud()
File "/home/travis/build/KAMI911/lactransformer/lactransformer/libs/LasPyConverter.py", line 133, in TransformPointCloud
self.__DestinationOpenedFile.x, self.__DestinationOpenedFile.y, self.__DestinationOpenedFile.z = transform(self.__SourceProj, self.__DestinationProj, self.__SourceOpenedFile.x, self.__SourceOpenedFile.y, self.__SourceOpenedFile.z)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/pyproj/init.py", line 507, in transform
_proj._transform(p1, p2, inx, iny, inz)
File "pyproj/_proj.pyx", line 302, in pyproj._proj._transform
File "pyproj/_proj.pyx", line 276, in pyproj._proj.TransProj.init
pyproj.exceptions.ProjError: Error creating CRS to CRS.

Is this a bug, o
r did I wrong something? From the documentation I can not see if I have to use Proj class differently.

snowman2 added a commit to snowman2/pyproj that referenced this issue Mar 13, 2019
@snowman2
Copy link
Member

snowman2 commented Mar 13, 2019

I confirmed this & made a fix in PR #189.

snowman2 added a commit to snowman2/pyproj that referenced this issue Mar 13, 2019
snowman2 added a commit to snowman2/pyproj that referenced this issue Mar 14, 2019
@KAMI911
Copy link
Author

KAMI911 commented Mar 15, 2019

Still not working with 2.1.0.
I have strange coordinates in degree, but no pyproj.exceptions.ProjError: Error creating CRS to CRS. exception.

@snowman2
Copy link
Member

Glad to hear the error is gone!

@KAMI911, the default for input/output for geographic projections is degrees. If you would prefer radians, you can use the radians=True flag on the transform.

@KAMI911
Copy link
Author

KAMI911 commented Mar 15, 2019

I am generally use meter based projections like:

               'WGS84geo': '+proj=geocent +ellps=WGS84 +datum=WGS84 +units=m +no_defs',

               'EOV': '+proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +units=m +no_defs',

               'EOVc': '+proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +nadgrids=' + nadgrids_EOV2014 + ' +geoidgrids=' + geoidgrids_EOV2014 + ' +units=m +no_defs',

               'EOV2014': '+proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +nadgrids=' + nadgrids_EOV2014 + ' +geoidgrids=' + geoidgrids_EOV2014 + ' +units=m +no_defs',

               'EOV2014fine': '+proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +nadgrids=' + nadgrids_EOV2014 + ' +geoidgrids=' + geoidgrids_EOV2014fine + ' +units=m +no_defs',

               'EOV2009': '+proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +nadgrids=' + nadgrids_EOV2009 + ' +geoidgrids=' + geoidgrids_EOV2009 + ' +units=m +no_defs',

As you can see I am using projection strings, as described here: https://pyproj4.github.io/pyproj/html/api/proj.html#pyproj-proj

It seems only the my program tests fail. I will look into.

@KAMI911
Copy link
Author

KAMI911 commented Mar 15, 2019

Maybe the default preserve_units=True can cause thus problem?

Proj('+proj=geocent +ellps=WGS84 +datum=WGS84 +units=m +no_defs', preserve_units=True)

When I try to force False with:

self.__SourceProj = Proj(self.__SourceProjectionString, preserve_units=False)

The preserve_units remains True.
Can you check this?

@snowman2
Copy link
Member

@KAMI911, that should be okay. The preserve_units=False just means that on load, convert any ft units to m. Once the conversion is complete, then to re-create it, the preserve_units=True with the modified string is correct.

Would you mind providing examples in code of what you are expecting versus what is actually happening?

@snowman2
Copy link
Member

snowman2 commented Mar 16, 2019

Input:

gridetrs = "/home/snowal/projects/pyproj/etrs2eov_notowgs.gsb"
gridgeoid = "/home/snowal/projects/pyproj/geoid_eht.gtx"
from pyproj import Proj, transform
proj1 = Proj('+proj=geocent +ellps=WGS84 +datum=WGS84 +units=m +no_defs ', preserve_units=True)
proj2 = Proj(f'+proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +nadgrids={gridetrs} +geoidgrids={gridgeoid} +units=m +no_defs ', preserve_units=True)

Output:

# version 1.9.6 (PROJ version 5.2.0)
>>> transform(proj1, proj2, 4072352.038, 1406781.664, 4687388.295)
(650742.19224405, 251070.04809174273, 123.85061213087161)
# version 2.1.0 (PROJ version 6.0.0)
>>> transform(proj1, proj2, 4072352.038, 1406781.664, 4687388.295)
(650657.5504410468, 251040.20088167512, 167.514173919335)

They seem very close, I wonder if it has to do with something that change in PROJ 6.0.0.

@snowman2
Copy link
Member

I see you use somerc in your projections. I wonder if it is related to OSGeo/PROJ#1234

@snowman2
Copy link
Member

snowman2 commented Mar 16, 2019

@kbevers @rouault, can you verify that this issue is related to a change in the code for PROJ?

This is essentially a proj_create_crs_to_crs & proj_trans_generic operation.

@snowman2
Copy link
Member

With PROJ 6.0.0:

$ cs2cs '+proj=geocent +ellps=WGS84 +datum=WGS84 +units=m +no_defs' '+proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +nadgrids=/home/snowal/projects/pyproj/etrs2eov_notowgs.gsb +geoidgrids=/home/snowal/projects/pyproj/geoid_eht.gtx +units=m +no_defs'
4072352.038 1406781.664 4687388.295      
650657.55	251040.20 167.51

@KAMI911
Copy link
Author

KAMI911 commented Mar 16, 2019

@snowman2: Yeah, you are right, it seems there small differences between the transformed coordinates. These are differences (in one example las file):

Xmin/max/avg/std: -84.6430/-84.6370/-84.6403/0.0014, Ymin/max/avg/std: -29.8510/-29.8460/-29.8485/0.0009, Zmin/max/avg/std: 43.6470/43.6650/43.6579/0.0029

@kbevers
Copy link
Contributor

kbevers commented Mar 16, 2019

@kbevers @rouault, can you verify that this issue is related to a change in the code for PROJ?

This is essentially a proj_create_crs_to_crs & proj_trans_generic operation.

It may be because the grids aren't picked up by proj_create_crs_to_crs:

$ ./bin/projinfo -o PROJ -s '+proj=geocent +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs' -t '+proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +nadgrids=/home/snowal/projects/pyproj/etrs2eov_notowgs.gsb +geoidgrids=/home/snowal/projects/pyproj/geoid_eht.gtx +units=m +no_defs +type=crs'
Candidate operations found: 1
-------------------------------------
Operation n°1:

unknown id, Transformation from unknown to unknown, unknown accuracy, unknown domain of validity

PROJ string:
+proj=pipeline +step +inv +proj=geocent +ellps=WGS84 +ellps=WGS84 +units=m +no_defs +step +proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +units=m +no_defs +vunits=m

The WKT output of the same call does include the grids, so this is likely a bug in PROJ.

@snowman2
Copy link
Member

Thanks for looking into this @kbevers @rouault!

@snowman2 snowman2 added bug proj Bug or issue related to PROJ labels Mar 17, 2019
@snowman2 snowman2 added this to the 2.1.2 milestone Mar 17, 2019
@KAMI911
Copy link
Author

KAMI911 commented Mar 20, 2019

Is this fix will be available in may when proj4 will be available with version 6.0.1?

@snowman2
Copy link
Member

I assume so, I think it has been merged in, so it should be included in the next release.

@snowman2 snowman2 modified the milestones: 2.2.?, 2.2.0 Apr 3, 2019
@snowman2 snowman2 added this to Done in 2.2.0 Release Apr 30, 2019
@snowman2
Copy link
Member

Confirming this has been fixed in PROJ 6.1.0.

>>> gridetrs = "/home/snowal/projects/pyproj/etrs2eov_notowgs.gsb"
>>> gridgeoid = "/home/snowal/projects/pyproj/geoid_eht.gtx"
>>> from pyproj import Proj, transform
>>> proj1 = Proj('+proj=geocent +ellps=WGS84 +datum=WGS84 +units=m +no_defs ', preserve_units=True)
>>> proj2 = Proj(f'+proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +nadgrids={gridetrs} +geoidgrids={gridgeoid} +units=m +no_defs ', preserve_units=True)
>>> transform(proj1, proj2, 4072352.038, 1406781.664, 4687388.295)
(650742.19224405, 251070.04809174273, 123.84865860538136)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug proj Bug or issue related to PROJ
Projects
No open projects
2.2.0 Release
  
Done
Development

No branches or pull requests

3 participants