ST_Segmentize

更新时间:
复制 MD 格式

Returns a modified geometry or geography object in which no segment is longer than the specified maximum length.

Syntax

geometry  ST_Segmentize(geometry geom, float maxSegmentLength);
geography ST_Segmentize(geography geog, float maxSegmentLength);

Parameters

ParameterDescription
geomThe input geometry object.
geogThe input geography object.
maxSegmentLengthThe maximum allowed segment length. For geometry inputs, the unit follows the spatial reference of the input. For geography inputs, the unit is meters.

Usage notes

  • Length is calculated in 2D only.

  • Segments shorter than maxSegmentLength are not modified.

Examples

LINESTRING — basic segmentation

The following example splits a line segment of length 1 into two equal subsegments of length 0.5:

SELECT ST_AsText(ST_Segmentize(ST_GeomFromText('LINESTRING(2 1,1 1)'), 0.5));

Output:

         st_astext
---------------------------
 LINESTRING(2 1,1.5 1,1 1)
(1 row)

The midpoint (1.5, 1) is inserted, splitting the original segment into two equal subsegments.

What's next