Vectorize all GEOS functions
See original GitHub issueVectorized functions would be a big help to GeoPandas and other projects trying to organize Shapely geometry in arrays, and there seems to be a consensus that it’s best to implement the vectorized GEOS functions within Shapely. (See https://github.com/geopandas/geopandas/issues/430#issuecomment-291083993.)
After taking a look through the code I think we could implement this without too much trouble by adding a version of topology.py that generates vectorized versions of the functions. At that point it would be easy to call the functions from the vectorized
module, or add them to the BaseGeometry
class, or call them in Geopandas (I think).
I just want to get some feedback to make sure I’m on the right track before I start this, and figure out where people should send the pull requests.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:35 (13 by maintainers)
Top GitHub Comments
For the last couple of weeks, I did some work on this on the side. Basically, I wrapped most of the GEOS function in numpy ufuncs using this example from the numpy docs.
I started out using @jorisvandenbossche and @mrocklin approach (great blog posts, these really got me started on this) by putting raw pointers in ndarrays. The problem with this is the memory management: you really have to call Destroy precisely once per pointer, else you are left with a memory leak or SIGABRTs because you try to free the same memory block twice.
I ended up with a numpy structured dtype that has the shapely object along with the pointer to the GEOSGeometry. This makes sure GEOSGeometries are deallocated.
The code is now at https://github.com/caspervdw/pygeos, but I am willing to make a PR to shapely if someone wants to review/help with integrating it in shapely.
Please excuse the self-advertisement, but we worked a bit on this. It’s summarized here
http://matthewrocklin.com/blog/work/2017/09/21/accelerating-geopandas-1 https://github.com/geopandas/geopandas/issues/473
There is probably new information about this now. I’m a bit out of date.
On Thu, Mar 7, 2019 at 2:56 PM Will May notifications@github.com wrote: