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

ENH: bounds function #62

Closed
jorisvandenbossche opened this issue Oct 21, 2019 · 5 comments
Closed

ENH: bounds function #62

jorisvandenbossche opened this issue Oct 21, 2019 · 5 comments

Comments

@jorisvandenbossche
Copy link
Member

Shapely has a bounds attribute, implemented at:

https://github.com/Toblerity/Shapely/blob/803b21bb87f3f76ce25bec4e015b46038c0df1f4/shapely/coords.py#L159-L186

I personally find this a useful operation that I use regularly. You can already get the coordinates per geometry and calculate the min/max of this, but doing that on an array of geometries still requires some manual looping.

Something to add to pygeos?

@jorisvandenbossche
Copy link
Member Author

jorisvandenbossche commented Oct 21, 2019

Postgis seems to have something related: ST_Extent (https://postgis.net/docs/ST_Extent.html). But this returns a "BOX" object instead of the 4 values as bounds does. And it is also an aggregation function (so it typically creates the bounding box of multiple geometries, I suppose, similarly to the total_bounds in GeoPandas)

The "spatial" equivalent is actually the pygeos.envelope function, which gives you the polygon representation of this bounding box. But from there it is still not that straightforward to get the 4 bounding coordinates.

@caspervdw
Copy link
Member

The GEOS C-API exposes Xmin, Xmax, Ymin, Ymax functions since version 3.7. That is probably what we need. I do wonder if performing the envelope and getting the values from the coordinate sequence would be more efficient.

@caspervdw
Copy link
Member

As discussed in #69, we would also like a total_bounds function

@brendan-ward
Copy link
Contributor

@caspervdw this appears resolved as of #69, #107

@jorisvandenbossche
Copy link
Member Author

Indeed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants