shapely.segmentize#
- segmentize(geometry, max_segment_length, **kwargs)#
Adds vertices to line segments based on maximum segment length.
Note
‘segmentize’ requires at least GEOS 3.10.0.
Additional vertices will be added to every line segment in an input geometry so that segments are no longer than the provided maximum segment length. New vertices will evenly subdivide each segment.
Only linear components of input geometries are densified; other geometries are returned unmodified.
- Parameters:
- geometryGeometry or array_like
- max_segment_lengthfloat or array_like
Additional vertices will be added so that all line segments are no longer than this value. Must be greater than 0.
- **kwargs
See NumPy ufunc docs for other keyword arguments.
Examples
>>> from shapely import LineString, Polygon >>> line = LineString([(0, 0), (0, 10)]) >>> segmentize(line, max_segment_length=5) <LINESTRING (0 0, 0 5, 0 10)> >>> polygon = Polygon([(0, 0), (10, 0), (10, 10), (0, 10), (0, 0)]) >>> segmentize(polygon, max_segment_length=5) <POLYGON ((0 0, 5 0, 10 0, 10 5, 10 10, 5 10, 0 10, 0 5, 0 0))> >>> segmentize(None, max_segment_length=5) is None True