MCPcopy Create free account
hub / github.com/shapely/shapely / _split_polygon_with_line

Method _split_polygon_with_line

shapely/ops.py:346–365  ·  view source on GitHub ↗

Split a Polygon with a LineString.

(poly, splitter)

Source from the content-addressed store, hash-verified

344class SplitOp:
345 @staticmethod
346 def _split_polygon_with_line(poly, splitter):
347 """Split a Polygon with a LineString."""
348 if not isinstance(poly, Polygon):
349 raise GeometryTypeError("First argument must be a Polygon")
350 if not isinstance(splitter, (LineString, MultiLineString)):
351 raise GeometryTypeError("Second argument must be a (Multi)LineString")
352
353 union = poly.boundary.union(splitter)
354
355 # greatly improves split performance for big geometries with many
356 # holes (the following contains checks) with minimal overhead
357 # for common cases
358 poly = prep(poly)
359
360 # some polygonized geometries may be holes, we do not want them
361 # that's why we test if the original polygon (poly) contains
362 # an inner point of polygonized geometry (pg)
363 return [
364 pg for pg in polygonize(union) if poly.contains(pg.representative_point())
365 ]
366
367 @staticmethod
368 def _split_line_with_line(line, splitter):

Callers

nothing calls this directly

Calls 6

GeometryTypeErrorClass · 0.90
prepFunction · 0.90
polygonizeFunction · 0.85
unionMethod · 0.80
representative_pointMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected