In shapely, a MultiPolygon is made of several disjoint Polygons (except one-point intersections). If I have a MultiPolygon polys
and a Point pt
, then I can test for containment by
polys.contains(pt)
which gives True
in case the point is in at least one of the polygons. I assume this is working efficiently on the inside by using some R-Tree. However, actually, I am interested, in which of the Polygons in the MultiPolygon the Point is contained. I wonder, whether there is a trick to identify it without testing through the list of polygons (ie, polys.geoms
)?
Any hint is appreciated - thanks already!!
You could always use the syntax
for poly in polys.geoms:
if poly.contains(pt):
print(poly)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.