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

would it be possible to have the CRS bounds in its original unit ? #809

Closed
12rambau opened this issue Mar 29, 2021 · 5 comments
Closed

would it be possible to have the CRS bounds in its original unit ? #809

12rambau opened this issue Mar 29, 2021 · 5 comments
Labels
proposal Idea for a new feature.

Comments

@12rambau
Copy link

Let's assume I want to get the bounds of the projection 'EPSG:3857' in meters (unit of the 3857 projection)

In the current implementation of pyproj and with my little knowledge I would do the following :

from pyproj import CRS, Transformer

in_crs = CRS.from_epsg(4326)
out_crs = CRS.from_epsg(3857)
x_min, y_min, x_max, y_max = out_crs.area_of_use.bounds

proj = Transformer.from_crs(4326, 3857, always_xy=True)
bl = proj.transform(x_min, y_min)
tr = proj.transform(x_max, y_max)

that's a lot of steps just to extract the bounds in the original proj unit.
Would it be possible to add a method to retrieve the projection in its original unit ?

I would be happy to PR this very code in PR if you agree with this way of computing it.

maybe I'm foolish and there is already a way to retrieve the bounds...

@12rambau 12rambau added the proposal Idea for a new feature. label Mar 29, 2021
@snowman2
Copy link
Member

To transform the boundary properly, would likely need a method similar to:
https://rasterio.readthedocs.io/en/latest/api/rasterio.warp.html#rasterio.warp.transform_bounds

@snowman2
Copy link
Member

@snowman2
Copy link
Member

snowman2 commented Apr 1, 2021

How to get projected bounds with #810:

from pyproj import CRS, Transformer

crs = CRS("EPSG:3857")
transformer = Transformer.from_crs(crs.geodetic_crs, crs, always_xy=True)
transformer.transform_bounds(*crs.area_of_use.bounds)

@12rambau
Copy link
Author

12rambau commented Apr 1, 2021

awesome ! thanks a lot

I have edited my answer on GIS.Stackexchange: https://gis.stackexchange.com/questions/390517/getting-projected-bounds-information-in-pyproj/392407#392407

let me know when it will be released !

@snowman2
Copy link
Member

Release is coming soon. Hopefully by the end of the week 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Idea for a new feature.
Projects
No open projects
Development

No branches or pull requests

2 participants