Skip to content
🎉 Apache Sedona 1.8.1 is now available! Check out the new features and improvements.

ST_Segmentize

Introduction: Returns a modified geometry having no segment longer than the given max_segment_length.

The length calculation is performed in 2D. When a segment is longer than the specified maximum length, it is split into multiple, equal-length subsegments.

Format: ST_Segmentize(geom: Geometry, max_segment_length: Double)

SQL Example Long segments are split evenly into subsegments no longer than the specified length. Shorter segments are not modified.

SELECT ST_AsText(ST_Segmentize(ST_GeomFromText('MULTILINESTRING((0 0, 0 1, 0 9),(1 10, 1 18))'), 5));

Output:

MULTILINESTRING((0 0,0 1,0 5,0 9),(1 10,1 14,1 18))

SQL Example

SELECT ST_AsText(ST_Segmentize(ST_GeomFromText('POLYGON((0 0, 0 8, 30 0, 0 0))'), 10));

Output:

POLYGON((0 0,0 8,7.5 6,15 4,22.5 2,30 0,20 0,10 0,0 0))