PostGISGeometry Constructors

ST_MakePoint

What is ST_MakePoint?

ST_MakePoint is a PostGIS function that constructs a POINT geometry from numeric X, Y, and optional Z and M coordinates. It is the workhorse constructor for turning numeric columns (longitude/latitude, projected X/Y, elevation, measure) into PostGIS geometries.

SQL
1ST_MakePoint(float x, float y)geometry
2ST_MakePoint(float x, float y, float z)geometry
3ST_MakePoint(float x, float y, float z, float m)geometry

ST_MakePoint always returns a geometry with SRID 0 — you must wrap the call in ST_SetSRID if you want the output to be spatially meaningful: ST_SetSRID(ST_MakePoint(lon, lat), 4326). Arguments are in axis order X, Y — for lat/lon data that means longitude first.

When would you use ST_MakePoint?

Use ST_MakePoint in INSERT and UPDATE statements to populate a geometry column from separate coordinate columns — for example when importing a CSV of sensors, stores, or events:

SQL
1UPDATE stores
2SET geom = ST_SetSRID(ST_MakePoint(lon, lat), 4326)
3WHERE geom IS NULL AND lon IS NOT NULL AND lat IS NOT NULL;

It is also the most common way to build a reference point for distance queries (ST_DWithin(geom, ST_SetSRID(ST_MakePoint(…), 4326), 1000)), or a vertex supplied to ST_MakeLine and ST_MakePolygon when constructing more complex geometries.

FAQs

Why is my ST_MakePoint result returning nothing from spatial queries?

Almost always an SRID issue. ST_MakePoint returns SRID 0 by default; queries against an indexed SRID-bound column skip non-matching SRIDs. Wrap in ST_SetSRID(..., 4326) (or the appropriate SRID) to match your column.

What is the difference between ST_MakePoint, ST_Point, and ST_PointFromText?

ST_MakePoint takes raw numeric arguments and returns SRID 0. ST_Point(x, y, srid) (PostGIS 3.2+) accepts an SRID directly. ST_PointFromText parses a WKT string. For raw coordinates, ST_Point with an SRID is the cleanest modern choice; ST_MakePoint remains fine when wrapped in ST_SetSRID.

In what order are the coordinates — longitude or latitude first?

X first, then Y. For EPSG:4326 that is longitude first, latitude second — swapping them is the single most common PostGIS bug. Always use ST_MakePoint(lon, lat), not ST_MakePoint(lat, lon).

Can I create points with Z (elevation) or M (measure) values?

Yes. Three arguments produces POINT Z, four produces POINT ZM. Use ST_MakePointM(x, y, m) if you want M without Z. Z and M are preserved through most downstream operators, but remember that 2D spatial predicates ignore them.