-
Notifications
You must be signed in to change notification settings - Fork 95
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
Switch to pyproj 2.3+ for Transformer and CRS objects #267
Comments
For 2:
|
Extra bonus of this hard requirement for pyresample is that we should then be able to switch our unit tests to do:
And let pyproj/PROJ handle the comparison complexity. |
@snowman2 Thanks for the feedback. If we were using this to transform from traditional geodetic lon/lat coordinates (say from a scientific dataset) to a projected CRS like (ex. |
Randomly inserted, but thought it might be helpful: https://pyproj4.github.io/pyproj/stable/gotchas.html#proj-not-a-generic-latitude-longitude-to-projection-converter |
The example I gave was if you wanted behavior similar to the |
Perfect! I think we want EPSG:4326 to do things the "right" way, but have been using Proj as that FAQ recommends not doing 😉 In the long run, in Satpy, I hope to be explicitly providing a CRS for the input data (could be geographic lon/lats or projected X/Y coordinates) and an explicit CRS for the output data. |
To make things clear, are CRS object still not thread safe ? |
Correct. CRS and Proj objects (and Transform objects @snowman2 ?) are not thread-safe. We should be sending the projection parameters to the threads (which can be easily serialized) and then create the CRS/Proj objects in each thread. |
It depends how you use them. They are not safe to share between multiple threads, but they are safe when used by only one thread at a time. This is also true for the Transformer, Proj, and Geod classes I believe. |
Sounds good @djhoese ! And thanks @snowman2 for your feedback! Another bonus: Seems like the transformation of space pixels in the geostationary projection to lat/lon would then return >>> latlong = CRS.from_dict({'proj': 'latlong'})
>>> geos = CRS.from_dict({'proj': 'geos', 'h': 35785831.0, 'units': 'm', 'lon_0': 0})
>>> t = Transformer.from_crs(geos, regular)
>>> t.transform(-5570248.686685662, -5567248.28340708)
(inf, inf) |
@sfinkens This has been this way for a long time. I think even with the |
Oh... Nevermind then :) |
Another thing I'm realizing needs to be decided on: How does the
Are we OK changing "Projection" to showing the WKT? I'm sure this will break some tests, but is something we should probably do. |
Using wkt in the string output will be way too verbose imo. |
Yes, but if the PROJ string doesn't fully describe a projection (not the case for some/most of our cases) then users will fall in to the trap of using |
One option would be to use the |
Update on thread safety: pyproj4/pyproj#782 |
@snowman2 are the thread safety changes released yet? |
And are there any performance concerns? Would passing two CRS WKT strings to another thread, then creating a Transformer object be better/faster than sending the transformer object itself? |
The will be included in the 3.1 release.
I am not aware of any,
Probably about the same. |
Background
Pyresample has used old pyproj interfaces for a long time and depends heavily on the
Proj
class to transform between lon/lat degree coordinates and X/Y projection coordinates. We also depend heavily on PROJ parameter dictionaries and strings. PROJ strings are overall deprecated and are unable of representing all Coordinate Reference Systems (CRS) out there. The PROJ library suggests WellKnownText (WKT).Forgive me for the lack of references to the claims in this issue.
Suggestions
Drop the custom
Proj
classes in:pyresample/pyresample/_spatial_mp.py
Lines 129 to 137 in 3d6d38d
These checks are meant to produce lon/lat degrees when dealing with a geographic CRS (
+proj=latlong
). As of pyproj 2.3.0 this is done by default. This current check also makes it so certain geographic CRSes are not possible (ex.+proj=latlong +pm=180
).Switch to the pyproj
Transformer
class for all currentProj
uses. It is the recommended interface and would go something like this (I think):Without the
always_xy=True
this would flip the expected/returned order of the axes. In the case of EPSG:4326, this expects latitude first, longitude second.Drop PROJ parameters as internally stored representation of CRS information. See Switch to storing CRS WKT in AreaDefinitions instead of the CRS object #264 for first attempts at storing WKT instead.
CC @snowman2 (pyproj maintainer). If you have any other suggestions, corrections, or other feedback, please let us know.
The text was updated successfully, but these errors were encountered: