Skip to content

ST_Simplify

Simplifies an input geometry or geography using the Douglas-Peucker algorithm.

Usage

geometry ST_Simplify(geom: geometry, tolerance: double)
geography ST_Simplify(geog: geography, tolerance: double)

Arguments

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

Description

Simplifies a geometry or geography using the Douglas-Peucker algorithm. The tolerance parameter controls the degree of simplification: higher values produce simpler geometries. For geography, the tolerance is specified in meters and a different algorithm is used.

This function may produce invalid geometries; use ST_SimplifyPreserveTopology when validity must be maintained.

Examples

SELECT ST_Simplify(
    ST_GeomFromWKT('LINESTRING (0 0, 0.5 0.1, 1 0, 1.5 0.1, 2 0)'),
    0.2
);
┌──────────────────────────────────────────────────────────────────────────────┐
 st_simplify(st_geomfromwkt(Utf8("LINESTRING (0 0, 0.5 0.1, 1 0, 1.5 0.1, 2 0 │
│                              )")),Float64(0.2))                             
╞══════════════════════════════════════════════════════════════════════════════╡
 LINESTRING(0 0,2 0)                                                          
└──────────────────────────────────────────────────────────────────────────────┘
SELECT ST_Simplify(
    ST_GeogFromWKT('LINESTRING (0 0, 0.5 0.1, 1 0, 1.5 0.1, 2 0)'),
    50000
);
┌──────────────────────────────────────────────────────────────────────────────┐
 st_simplify(st_geogfromwkt(Utf8("LINESTRING (0 0, 0.5 0.1, 1 0, 1.5 0.1, 2 0 │
│                              )")),Int64(50000))                             
╞══════════════════════════════════════════════════════════════════════════════╡
 LINESTRING(0 0,2 0)                                                          
└──────────────────────────────────────────────────────────────────────────────┘