ST_MakePointM

更新时间:
复制 MD 格式

Creates a PointM geometry using x, y, and m (measure) coordinates.

Use ST_MakePoint instead if you need XY, XYZ, or XYZM coordinates. To create a PointM with a specific spatial reference system, combine ST_MakePointM with ST_SetSRID.

Syntax

geometry ST_MakePointM(float x, float y, float m);

Parameters

Parameter

Description

x

Longitude of the point.

y

Latitude of the point.

m

Measure value of the point. The m coordinate is not a spatial dimension. Use it to store user-defined measurements such as timestamps, cumulative distance, or elevation along a path.

Pass longitude as x and latitude as y. This order is the opposite of the conventional "latitude, longitude" notation and is a common source of errors.

Examples

Create a PointM geometry

ST_AsEWKT is used in the examples below because ST_AsText does not output M values.

SELECT ST_AsEWKT(ST_MakePointM(1, 2, 3));

Output:

   st_asewkt
---------------
 POINTM(1 2 3)
(1 row)

Create a PointM geometry with a spatial reference system

Use ST_SetSRID to assign a spatial reference system identifier (SRID). The following example assigns SRID 4326 (WGS 84).

SELECT ST_AsEWKT(ST_SetSRID(ST_MakePointM(-71.104, 42.315, 10), 4326));

Output:

              st_asewkt
-----------------------------------------
 SRID=4326;POINTM(-71.104 42.315 10)
(1 row)

Extract the M value from a PointM geometry

Use ST_M to retrieve the measure value from a PointM geometry.

SELECT ST_M(ST_MakePointM(-71.104, 42.315, 10));

Output:

 st_m
------
   10
(1 row)

What's next