Returns a geometry whose coordinate values are rounded to a specified number of significant digits.
Syntax
geometry ST_QuantizeCoordinates(geometry g, int precX, int precY, int precZ, int precM);Parameters
| Parameter | Description |
|---|---|
g | The geometry object to operate on. |
precX | The number of decimal places for x coordinate values. |
precY | The number of decimal places for y coordinate values. |
precZ | The number of decimal places for z coordinate values. |
precM | The number of decimal places for m coordinate values. |
Usage notes
ST_QuantizeCoordinatessets all non-significant digits in a coordinate value to 0. The result rounds to the original coordinate value, but with higher compressibility. If the geometry column uses a compressible storage type, this reduces disk usage.The function does not affect the size of geometry objects in memory.
The function does not affect existing topological relationships between geometry objects.
If no precision is specified for a coordinate dimension, the precision of the x coordinate is used.
Negative parameter values treat significant digits as positions to the left of the decimal point. For example, setting
precXto-2preserves the x coordinate to the nearest 100.If the specified precision is lower than the intrinsic precision of the geometry object, the function may return an invalid geometry.
Examples
Round a point's coordinates to 4 significant digits:
SELECT ST_AsEWKT(ST_QuantizeCoordinates(ST_GeomFromText('POINT(1.123456 1.123456)'), 4));Output:
st_asewkt
------------------------------------------
POINT(1.12345123291016 1.12345123291016)
(1 row)