Date
1 - 7 of 7
Interconverting between pyproj and rasterio CRS objects
Nick Weir <nicholas.r.weir@...>
Hi there!
Now that geopandas is using pyproj CRS objects as the default for tracking CRSs in GeoDataFrames, I'm finding myself needing to figure out a way to frequently check identity and interconvert back and forth between pyproj.crs.CRS objects and rasterio.crs.CRS objects. However, I'm having a hard time figuring out the "ideal" way to do this. It's great that the following works:
I'm trying to figure out the best way to pass around CRSs within a python library (ideally in a single object type) and encountering issues. I don't want to wed myself to using EPSG codes to interconvert between objects, because I want to be able to accommodate CRSs/SRSs without codes. However, I'm finding problems using something else (like a WKT string) to convert between rasterio.crs.CRSs and pyproj.crs.CRSs. For example:
Fails. Any thoughts? I could definitely be missing something here. Thanks! -N |
||||
|
||||
Alan Snow
Here are instructions for rasterio to geopandas: https://gis.stackexchange.com/a/350231/144357
For geopandas to rasterio, you will need something like:
|
||||
|
||||
vincent.sarago@...
FYI: https://github.com/corteva/rioxarray/issues/92 and https://github.com/corteva/rioxarray/issues/92
|
||||
|
||||
Nick Weir <nicholas.r.weir@...>
Yeah, this of course works. I'm more thinking from a philosophical standpoint of "which object works better to pass around?"
It seems like the pyproj objects work a bit better. And that's what's natively used in geopandas and a bunch of other places. I guess the question becomes "what's the benefit of rasterio having its own CRS object type"...I guess the main argument against is that adding pyproj is adding an additional dependency? See this gist for a bit of exploration of this. |
||||
|
||||
Alan Snow
Add some history for reference: https://rasterio.groups.io/g/dev/topic/switch_from_proj_4_format_to/28991934
|
||||
|
||||
Sean Gillies
Hi Nick, Rasterio has its own CRS class because pyproj 2 didn't exist at the time. On Thu, Mar 5, 2020 at 9:47 AM Nick Weir <nicholas.r.weir@...> wrote: Yeah, this of course works. I'm more thinking from a philosophical standpoint of "which object works better to pass around?" --
Sean Gillies |
||||
|
||||
Nick Weir <nicholas.r.weir@...>
Got it. Forgot that there wasn’t a class there previously...thanks for the context! -- Sent from my mobile. |
||||
|