ST_Perimeter2D
What is ST_Perimeter2D?
ST_Perimeter2D returns the 2D perimeter of a polygonal geometry. It is effectively an alias of ST_Perimeter for geometry input and exists primarily for API symmetry with ST_3DPerimeter.
ST_Perimeter2D(geometry geomA) → floatAny Z values are ignored. The result is in the CRS units of the input.
When would you use ST_Perimeter2D?
Use ST_Perimeter2D when you want to be explicit that you are measuring plan-view perimeter on 3D data — useful when reporting both the planimetric and slope perimeters of polygons draped over terrain, or when auditing footprint boundary lengths independent of elevation.
1-- Ratio of slope perimeter to plan perimeter
2SELECT id,
3 ST_3DPerimeter(geom) / NULLIF(ST_Perimeter2D(geom), 0) AS slope_factor
4FROM building_footprints;FAQs
How does it differ from ST_Perimeter?
For geometry input they return the same value. ST_Perimeter2D names the 2D intent explicitly; only ST_Perimeter accepts geography.
What units does it return?
The CRS units of the input — degrees for EPSG:4326, metres for most projected CRSs. There is no geography overload.
Does it include holes?
Yes, the total includes the outer ring and all interior rings of each polygon part.
What does it return for non-polygonal input?
Zero. For linestring length use ST_Length/ST_Length2D.