This topic describes the ST_MakePoint function. This function constructs a 2D, 3DZ, or 4D point object.

Syntax

geometry  ST_MakePoint(double precision  x , double precision  y);
geometry  ST_MakePoint(double precision  x , double precision  y , double precision  z);
geometry  ST_MakePoint(double precision  x , double precision  y , double precision  z , double precision  m);

Parameters

ParameterDescription
xThe x coordinate, which represents the longitude of the point object.
yThe y coordinate, which represents the latitude of the point object.
zThe z coordinate of the point object.
mThe m coordinate of the point object.

Description

  • The ST_MakePoint function constructs a geometry object in a faster and more accurate manner than the ST_GeomFromText function and the ST_PointFromText function.
  • If you want to construct a 3DM point object, use the ST_MakePointM function.
  • The ST_MakePoint function supports 3D objects and does not discard the z-index of the geometry object that is constructed.

Examples

  • Construct a 2D object.
    SELECT ST_AsText(ST_MakePoint(1,2));
     st_astext
    ------------
     POINT(1 2)
    (1 row)
                        
  • Construct a 3DZ point object.
    SELECT ST_AsText(ST_MakePoint(1,2,3));
        st_astext
    -----------------
     POINT Z (1 2 3)
    (1 row)
                        
  • Create a 4D object.
    SELECT ST_AsText(ST_MakePoint(1,2,3,4));
         st_astext
    --------------------
     POINT ZM (1 2 3 4)
    (1 row)