ST_MakePointM
What is ST_MakePointM?
ST_MakePointM is a PostGIS function that constructs a POINT M — a 2D point carrying an M (measure) coordinate but no Z (elevation). It is the correct constructor when you need the measure dimension without the elevation.
ST_MakePointM(float x, float y, float m) → geometryLike ST_MakePoint, it returns SRID 0; wrap in ST_SetSRID for spatial queries. M values are used by linear referencing functions (ST_LocateAlong, ST_InterpolatePoint, etc.) to represent stationing, time, or any scalar along a route.
When would you use ST_MakePointM?
Use ST_MakePointM when the measure value matters but elevation does not — classic examples are linear-referencing workflows along roads, pipelines, or rivers, where M represents kilometre post, chainage, or flow distance. Vehicle trajectories with a time-as-M channel are another common case.
1INSERT INTO milestones (route_id, post_m, geom)
2SELECT r.id,
3 m.km,
4 ST_SetSRID(ST_MakePointM(m.lon, m.lat, m.km), 4326)
5FROM staging_milestones m
6JOIN routes r USING (route_code);If your source data has both elevation and measure, use ST_MakePoint(x, y, z, m) instead — ST_MakePointM is the two-plus-measure variant.
FAQs
How does ST_MakePointM differ from ST_MakePoint?
ST_MakePoint(x, y, m) with three arguments creates POINT Z — the third argument is interpreted as elevation. ST_MakePointM explicitly marks the third value as M. If you need measure semantics, always use ST_MakePointM to avoid silent type confusion.
What is an M coordinate used for?
M stands for "measure" — a scalar associated with each vertex, typically used for linear referencing (distance along a route, time, or other attribute). PostGIS functions like ST_LocateAlong and ST_AddMeasure operate on M.
Do spatial predicates consider the M value?
No. Standard 2D predicates (ST_Intersects, ST_Contains, ST_DWithin) ignore M and Z. M is preserved in the geometry and accessible via ST_M(point), but it does not influence containment or distance calculations.
Which SRID does the result have?
SRID 0 by default, just like ST_MakePoint. Wrap in ST_SetSRID to match your target column or spatial queries will silently miss the index.