David Fawcett
2013-03-26 21:17:22 UTC
I am thinking through the logic for efficiently overlaying ~10,000 points
on ~100 polys. What I want in the end is a list of dicts holding the
string ID for the point and string ID for the intersecting Poly. I have
an example with prepared geometries, but now I am working up an RTree
example to benchmark.
Here is the logic:
- I use RTree to create an index on my polys
- at the same time, I create a dict to lookup the string ID (stationID) for
the integer index value
- I loop through the points in my collection and test them against the
index.
- if only one intersection is returned, I grab the id and look up my
countyID.
- if my intersection operation on the index returns multiple poly IDs, I
need to test against the actual geometries.
This is where I am struggling. I don't see a way to access a specific
feature from a shapely collection based on a property. My first idea is to
store the polygon features in a dictionary after reading them from the
shapefile. This would give me access by ID. At the same time, I am trying
to work within the Shapely data structures.
Does anyone have any suggestions on best practices for integrating RTree
and Shapely? Specifically, how you relate geometry collections to RTree
indexes.
I will post a code example after I modify my current example to not use
external data sources.
Thanks,
David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20130326/891ca131/attachment.htm>
on ~100 polys. What I want in the end is a list of dicts holding the
string ID for the point and string ID for the intersecting Poly. I have
an example with prepared geometries, but now I am working up an RTree
example to benchmark.
Here is the logic:
- I use RTree to create an index on my polys
- at the same time, I create a dict to lookup the string ID (stationID) for
the integer index value
- I loop through the points in my collection and test them against the
index.
- if only one intersection is returned, I grab the id and look up my
countyID.
- if my intersection operation on the index returns multiple poly IDs, I
need to test against the actual geometries.
This is where I am struggling. I don't see a way to access a specific
feature from a shapely collection based on a property. My first idea is to
store the polygon features in a dictionary after reading them from the
shapefile. This would give me access by ID. At the same time, I am trying
to work within the Shapely data structures.
Does anyone have any suggestions on best practices for integrating RTree
and Shapely? Specifically, how you relate geometry collections to RTree
indexes.
I will post a code example after I modify my current example to not use
external data sources.
Thanks,
David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20130326/891ca131/attachment.htm>