Skip to content

ST_Segmentize

Densifies a geometry by adding intermediate points along segments that exceed a maximum length.

Usage

geometry ST_Segmentize(geom: geometry, max_segment_length: double)
geography ST_Segmentize(geog: geography, max_segment_length: double)

Arguments

  • geog (geography): Input geography
  • max_segment_length (double)
  • geom (geometry): Input geometry

Description

Densifies a geometry or geography by adding intermediate points along line segments that exceed the specified maximum segment length. For geometry, uses planar distance; for geography, uses the spherical approximation of the geodesic distance in meters and points are added along the great circle arc. In both cases, points are added so that each resulting segment is no longer than max_segment_length.

Examples

SELECT ST_Segmentize(
    ST_GeomFromText('LINESTRING (0 0, 0 10)'),
    2
);
┌─────────────────────────────────────────────────────────────────────────┐
│ st_segmentize(st_geomfromtext(Utf8("LINESTRING (0 0, 0 10)")),Int64(2)) │
│                                 geometry                                │
╞═════════════════════════════════════════════════════════════════════════╡
│ LINESTRING(0 0,0 2,0 4,0 6,0 8,0 10)                                    │
└─────────────────────────────────────────────────────────────────────────┘
SELECT ST_Segmentize(
    ST_GeogFromWKT('LINESTRING (0 0, 0 10)'),
    100000
);
┌──────────────────────────────────────────────────────────────────────────────┐
│  st_segmentize(st_geogfromwkt(Utf8("LINESTRING (0 0, 0 10)")),Int64(100000)) │
│                                   geography                                  │
╞══════════════════════════════════════════════════════════════════════════════╡
│ LINESTRING(0 0,0 0.8333333333333331,0 1.666666666666666,0 2.499999999999999… │
└──────────────────────────────────────────────────────────────────────────────┘