I would like to get the intersection of multiple polygons. Using Python's shapely
package, I can find the intersection of two polygons using the intersection
function. Is there a similar efficient function for obtaining the intersection of multiple polygons?
Here is a code snippet to understand what I mean:
from shapely.geometry import Point
coord1 = ( 0,0 )
point1 = Point(coord1)
circle1 = point1.buffer(1)
coord2 = ( 1,1 )
point2 = Point(coord2)
circle2 = point2.buffer(1)
coord3 = ( 1,0 )
point3 = Point(coord3)
circle3 = point3.buffer(1)
An intersection of two circles can be found by circle1.intersection(circle2)
. I can find the intersection of all three circles by circle1.intersection(circle2).intersection(circle3)
. However, this approach is not salable to a large number of polygons as it requires increasingly more code. I would like a function that takes an arbitrary number of polygons and returns their intersection.
No comments:
Post a Comment