PostGISMeasurement

ST_3DPerimeter

What is ST_3DPerimeter?

ST_3DPerimeter returns the 3D perimeter of a polygonal geometry — the sum of segment lengths in (x, y, z) space for each ring. For 2D input (no Z) it is equivalent to ST_Perimeter.

SQL
ST_3DPerimeter(geometry geomA)float

The result is in the CRS units of the input — typically metres for projected 3D data. There is no geography overload.

When would you use ST_3DPerimeter?

Use ST_3DPerimeter whenever elevation affects boundary length — polygons draped over terrain in a CityGML footprint, 3D cadastral parcels on slopes, or roof outlines in a BIM model. The 3D perimeter is always greater than or equal to the 2D perimeter; the ratio is a quick proxy for slope roughness along the boundary.

SQL
1-- Boundary slope surcharge vs. plan
2SELECT id,
3       ST_3DPerimeter(geom) - ST_Perimeter2D(geom) AS slope_surcharge_m
4FROM terrain_parcels;

FAQs

What if the geometry is 2D?

Missing Z values are treated as 0, so the result matches ST_Perimeter. Ensure input is genuinely 3D to get slope-aware perimeters.

Does it include holes?

Yes. Interior rings contribute their full 3D length, just like the outer ring.

Which geometry types are supported?

POLYGON and MULTIPOLYGON. Non-polygonal types return 0. Triangles and TINs are supported from PostGIS 2.2+.

Is there a geography version?

No. For spheroidal 3D perimeter on lat/lon data, reproject to a projected CRS in metres with ST_Transform first.