ST_MakePoint

Name

ST_MakePoint — Creates a 2D, 3DZ or 4D Point.

Synopsis

geometry ST_MakePoint ( float x , float y ) ;

geometry ST_MakePoint ( float x , float y , float z ) ;

geometry ST_MakePoint ( float x , float y , float z , float m ) ;

Description

Creates a 2D XY, 3D XYZ or 4D XYZM Point geometry. Use ST_MakePointM to make points with XYM coordinates.

Use ST_SetSRID to specify a SRID for the created point.

While not OGC-compliant, ST_MakePoint is faster than ST_GeomFromText and ST_PointFromText . It is also easier to use for numeric coordinate values.

[Note]

For geodetic coordinates, X is longitude and Y is latitude

[Note]

The functions ST_Point , ST_PointZ , ST_PointM , and ST_PointZM can be used to create points with a given SRID.

This function supports 3d and will not drop the z-index.

Examples

This example creates a point with an unknown SRID.

Code
SELECT ST_MakePoint(-71.1043443253471, 42.3150676015829);

This example creates a point in the WGS 84 geodetic CRS.

Code
SELECT ST_SetSRID(ST_MakePoint(-71.1043443253471, 42.3150676015829), 4326);

This example creates a 3D point with altitude.

Code
SELECT ST_MakePoint(1, 2, 1.5);

This example returns the Z coordinate of a point.

Code
SELECT ST_Z(ST_MakePoint(1, 2, 1.5));
Output
1.5