Skip to content

ST_ReducePrecision

Reduces the coordinate precision of a geometry or geography to the specified grid size.

Usage

geography ST_ReducePrecision(geog: geography, grid_size: double)

Arguments

  • geog (geography): Input geography
  • grid_size (double)

Description

Rebuilds a new geometry after specifying all vertices to the specified size. Z and M values are preserved but not affected by the grid snapping. The implementation is similar to a unary union and is designed to output valid geometry (e.g., by avoiding creating new crossing edges when snapping vertices).

Examples

SELECT ST_ReducePrecision(
    ST_GeogFromWKT('POINT (1.123456 2.654321)'),
    0.01
);
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_reduceprecision(st_geogfromwkt(Utf8("POINT (1.123456 2.654321)")),Float64 │
│                                   (0.01))…                                   │
╞══════════════════════════════════════════════════════════════════════════════╡
│ POINT(1.12 2.6500000000000004)                                               │
└──────────────────────────────────────────────────────────────────────────────┘