This topic describes the ST_QuantizeCoordinates function. This function returns a geometry object whose coordinate values are displayed in a specific number of significant digits.

Syntax

geometry  ST_QuantizeCoordinates (geometry  g , int  precX , int  precY , int  precZ , int  precM);

Parameters

ParameterDescription
gThe geometry object that you want to specify.
precXThe parameter that is used to specify the decimal places of the values of the x coordinates.
precYThe parameter that is used to specify the decimal places of the values of the y coordinates.
precZThe parameter that is used to specify the decimal places of the values of the z coordinates.
precMThe parameter that is used to specify the decimal places of the values of the m coordinates.

Description

  • The ST_QuantizeCoordinates function sets all digits in a coordinate value to 0 except the significant digits.
    • The obtained coordinate value is rounded to the original coordinate value of the geometry object. However, the compressibility of coordinate values is improved. If the columns of the geometry object use a compressible storage type, you can compress the data to reduce the disk usage.
    • The ST_QuantizeCoordinates function does not affect the sizes of the geometry objects that are stored in memory.
  • If you do not specify a precision for values of a coordinate, the precision of values of the x coordinates is assumed to be the precision of values of the coordinates.
  • If you specify a negative value for a parameter, the significant digits to display in a coordinate value are digits to the left of the decimal point.
    Note If you set the precX parameter to -2, the significant digits to display in a coordinate value are two digits to the left of the decimal point. The ST_QuantizeCoordinates preserves the coordinate value to the nearest 100.
  • The ST_QuantizeCoordinates function does not affect existing topological relationships between geometry objects.
  • If the number of significant digits lower than the intrinsic precision of a geometry object is called, the ST_QuantizeCoordinates function may return an invalid geometry object

Examples

SELECT ST_AsEWKT(ST_QuantizeCoordinates(ST_GeomFromText('POINT(1.123456 1.123456)'),4));
                st_asewkt
------------------------------------------
 POINT(1.12345123291016 1.12345123291016)
(1 row)