Name

ST_LengthSpheroid — Renvoie la longueur/périmètre 2D ou 3D d'une géométrie lon/lat sur un sphéroïde.

Synopsis

float ST_LengthSpheroid(geometry a_geometry, spheroid a_spheroid);

Description

Calcule la longueur ou le périmètre d'une géométrie sur un ellipsoïde. Ceci est utile si les coordonnées de la géométrie sont en longitude/latitude et qu'une longueur est souhaitée sans reprojection. Le sphéroïde est spécifié par une valeur textuelle comme suit :

SPHEROID[<NAME>,<SEMI-MAJOR AXIS>,<INVERSE FLATTENING>]

Par exemple :

SPHEROID["GRS_1980",6378137,298.257222101]

Disponibilité : 1.2.2

Modifié : 2.2.0 Dans les versions précédentes, cette fonction s'appelait ST_Length_Spheroid et avait l'alias ST_3DLength_Spheroid

Cette fonction prend en charge la 3D et ne supprime pas l'indice z.

Exemples

SELECT ST_LengthSpheroid( geometry_column,
                          'SPHEROID["GRS_1980",6378137,298.257222101]' )
                          FROM geometry_table;

SELECT ST_LengthSpheroid( geom, sph_m ) As tot_len,
ST_LengthSpheroid(ST_GeometryN(geom,1), sph_m) As len_line1,
ST_LengthSpheroid(ST_GeometryN(geom,2), sph_m) As len_line2
                          FROM (SELECT ST_GeomFromText('MULTILINESTRING((-118.584 38.374,-118.583 38.5),
        (-71.05957 42.3589 , -71.061 43))') As geom,
CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m)  as foo;
        tot_len      |    len_line1     |    len_line2
------------------+------------------+------------------
 85204.5207562955 | 13986.8725229309 | 71217.6482333646

 --3D
SELECT ST_LengthSpheroid( geom, sph_m ) As tot_len,
ST_LengthSpheroid(ST_GeometryN(geom,1), sph_m) As len_line1,
ST_LengthSpheroid(ST_GeometryN(geom,2), sph_m) As len_line2
                          FROM (SELECT ST_GeomFromEWKT('MULTILINESTRING((-118.584 38.374 20,-118.583 38.5 30),
        (-71.05957 42.3589 75, -71.061 43 90))') As geom,
CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m)  as foo;

         tot_len      |    len_line1    |    len_line2
------------------+-----------------+------------------
 85204.5259107402 | 13986.876097711 | 71217.6498130292

Voir aussi

ST_GeometryN, ST_Length