-
Notifications
You must be signed in to change notification settings - Fork 213
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
Support transformations of coordinates given as numpy arrays #4
Comments
I just came across this as well. What the heck is going on there? |
I also had a problem today when I wished to use the support for arrays but encountered the following error when passing an array of shape n,2 to the projection instance: ValueError: need more than 1 value to unpack. The documentation should at least be changed so as not to mislead people into thinking that there is support for arrays. |
Same error for me. Can someone give an explanation of why numpy arguments are no longer supported? It would help a lot if fixed. |
I think Transformer.transform() recently introduced with #189 closes this longstanding issue. |
Here is the current recommended method to transform 2D numpy arrays with pyproj 2.x: >>> from shapely.geometry import LineString, Point
>>> import numpy
>>> ll = LineString([Point(ii, ii) for ii in numpy.arange(0, 90, 0.01)])
>>> points = numpy.asarray(ll)
>>> points
array([[0.000e+00, 0.000e+00],
[1.000e-02, 1.000e-02],
[2.000e-02, 2.000e-02],
...,
[8.997e+01, 8.997e+01],
[8.998e+01, 8.998e+01],
[8.999e+01, 8.999e+01]])
>>> from pyproj import Transformer
>>> transformer = Transformer.from_crs("epsg:4326", "epsg:3857")
>>> points_3857 = numpy.empty(points.shape)
>>> points_3857[:, 0], points_3857[:, 1] = transformer.transform(points[:, 0], points[:, 1])
>>> points_3857
array([[0.00000000e+00, 0.00000000e+00],
[1.11319491e+03, 1.11319491e+03],
[2.22638982e+03, 2.22638986e+03],
...,
[1.00154146e+07, 5.26064404e+07],
[1.00165278e+07, 5.51925525e+07],
[1.00176410e+07, 5.96135402e+07]]) |
I believe with #38 and #4 (comment), this issue has been resolved. Feel free to continue the discussion if you have further questions. |
The docstring of
Proj.__call__
states that it would be possible to pass anndarray
of shape(n,2)
, but the supporting code is commented out in__call__
as well as the cython defined methods of_invn
and_fwdn
.What is the problem with these? It would help a lot if they were supported again.
The text was updated successfully, but these errors were encountered: