Functions / PostGIS / ST_PointZ
PostGISGeometry Constructors

ST_PointZ

What is ST_PointZ?

ST_PointZ is a PostGIS function (added in 3.2) that constructs a 3D POINT Z from X, Y, Z coordinates and an explicit SRID. It is the modern replacement for the older ST_SetSRID(ST_MakePoint(x, y, z), srid) idiom when you need a point with elevation.

SQL
ST_PointZ(float x, float y, float z, integer srid)geometry

Z typically represents elevation (metres above ellipsoid or sea level depending on the CRS), but can be used for any third dimension — depth, altitude, or a secondary scalar.

When would you use ST_PointZ?

Use ST_PointZ for any 3D dataset where elevation matters — terrain sampling, airspace corridors, building footprints with floor heights, subsurface wells, or drone flight paths:

SQL
1INSERT INTO well_heads (id, geom)
2VALUES (101, ST_PointZ(-102.34, 31.87, -1250.5, 4326));

Z values flow through most geometry functions (ST_Length, ST_Distance) in their 2D-ignoring form, but the 3D-aware variants (ST_3DDistance, ST_3DLength, ST_3DDWithin) take Z into account. If you only need measure (M), use ST_PointM; for both, use ST_PointZM.

FAQs

What is the difference between ST_PointZ and ST_MakePoint(x,y,z)?

ST_MakePoint(x, y, z) returns a POINT Z with SRID 0. ST_PointZ(x, y, z, srid) lets you supply the SRID inline, which matches modern PostGIS conventions and avoids the common SRID-0 pitfall.

Do standard spatial predicates use the Z coordinate?

No. ST_Intersects, ST_Contains, ST_DWithin, and their peers operate in 2D and ignore Z. Use the 3D-aware variants (ST_3DIntersects, ST_3DDWithin, ST_3DDistance) when Z matters.

Which PostGIS version introduced ST_PointZ?

PostGIS 3.2. On older versions use ST_SetSRID(ST_MakePoint(x, y, z), srid) instead.

What units does Z use?

Whatever the CRS and your data use. PostGIS does not enforce or interpret Z units. For EPSG:4326 it is typically metres above a reference surface, but this is a convention — document it per column.