Re: Get PROJ.4 representation of CRS object


Sean Gillies
 

Hi,

Rasterio's CRS.to_dict and .to_prog4 *do* return PROJ4 mappings and strings but we reduce to +init=epsg:xxxx when allowed. In the new world where there is no longer an epsg file to init from, it makes more sense to return the expanded PROJ4 form, I agree. We could do this for 1.2.0 at the risk of breaking programs with code like

epsg_code = crs.to_dict()["init"].split(":")[-1]

Nobody should need to do that as we have a .to_epsg method, but one of the laws of library development is that there will be some users critically dependent on any public property of the library, no matter if it was exposed by accident or by intent :)


On Sat, Dec 26, 2020 at 10:29 AM Denis Rykov <rykovd@...> wrote:
Thanks! This is exactly what I was looking for.

BTW GDAL has an appropriate method to export CRS to proj4:

>>> srs.ExportToProj4()
'+proj=utm +zone=5 +datum=WGS84 +units=m +no_defs '

In my opinion it would be nice to have it in rasterio.CRS as well.

On Sun, Dec 27, 2020 at 12:19 AM Alan Snow <alansnow21@...> wrote:
pyproj.CRS has a to_proj4 method that should be able to do that: https://pyproj4.github.io/pyproj/stable/examples.html,_._,_

--
Sean Gillies

Join main@rasterio.groups.io to automatically receive all group messages.