(poly, splitter)
return [pg for pg in polygonize(union) if poly.contains(pg.representative_point())]
Split a Polygon with a LineString
Split a Polygon with a LineString
Split a Polygon with a LineString
def _split_polygon_with_line(poly, splitter):
        """Split a Polygon with a LineString"""

        assert(isinstance(poly, Polygon))
        assert(isinstance(splitter, LineString))

        union = poly.boundary.union(splitter)

        # some polygonized geometries may be holes, we do not want them
        # that's why we test if the original polygon (poly) contains
        # an inner point of polygonized geometry (pg)
        return [pg for pg in polygonize(union) if poly.contains(pg.representative_point())]
def _split_polygon_with_line ( poly , splitter ) : assert ( isinstance ( poly , Polygon ) ) assert ( isinstance ( splitter , LineString ) ) union = poly . boundary . union ( splitter ) # some polygonized geometries may be holes, we do not want them # that's why we test if the original polygon (poly) contains # an inner point of polygonized geometry (pg) return [ pg for pg in polygonize ( union ) if poly . contains ( pg . representative_point ( ) ) ]