PostGIS
Description
Returns the 3-dimensional or 2-dimensional length of the geometry if it is a LineString or MultiLineString. For 2-d lines it will just return the 2-d length (same as ST_Length and ST_Length2D)
This function supports 3d and will not drop the z-index.
This method implements the SQL/MM specification.
SQL-MM IEC 13249-3: 7.1, 10.3
Changed: 2.0.0 In prior versions this used to be called ST_Length3D
Examples
Return length in feet for a 3D cable. Note this is in feet because EPSG:2249 is Massachusetts State Plane Feet
SELECT ST_3DLength(ST_GeomFromText('LINESTRING(743238 2967416 1,743238 2967450 1,743265 2967450 3,
743265.625 2967416 3,743238 2967416 3)',2249));
ST_3DLength
-----------
122.704716741457