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
| Parameter | Description |
|---|---|
geom | The input geometry object. |
geog | The input geography object. |
maxSegmentLength | The 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
maxSegmentLengthare 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
该文章对您有帮助吗?