[WIP] Convert shapely geometries#47
Conversation
|
Do we really need to go through C here? We will have the interpreter overhead anyway as shapely stores its GEOSGeometry pointer in a (dynamic) attribute. |
|
How would you convert a shapely object into a pygeos object on the python level? (without going through WKB) |
Calling the GEOSClone function on a pointer originating from a Python int is asking for problems. It will be easy to get segfaults. Also I am thinking about GEOS versioning issues. I was thinking about WKB indeed. In general I like using stable API protocols like that. Does it add that much overhead? |
That's what Shapely is doing all the time .. Will do a check of performance difference between both options. |
|
I did a quick check, and to give an idea of the speed-up, for an array of 100000 shapely points, going through WKB takes ~960ms, while the method in this PR (cloning) takes ~40ms. But ok, for now this is not a blocker, and agree that GEOS versioning issues makes this problematic. But when we think again about better integration with shapely, this might something to reconsider. |
This PR adds a
from_shapelyfunctionality, to convert an array of shapely objects into pygeos objects.This is something I will often need to use pygeos in GeoPandas (since all (testing) code their is written to handle shapely input).
Work in progress for now, the None handling is not yet working.