ST_Segmentize

更新时间:
复制 MD 格式

Returns a modified geometry or geography having no segment longer than a given distance. Short segments are left unchanged.

Syntax

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

Parameters

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

Usage notes

  • Length is calculated in 2D only.

Only segments longer than maxSegmentLength are split. Segments shorter than maxSegmentLength are not modified.

Examples

Segmentize a line

The 1-unit segment (2 1, 1 1) is split into two 0.5-unit subsegments, adding vertex (1.5 1).

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

Expected output:

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

See also