ST_Length_Spheroid — LINESTRINGまたはMULTILINESTRINGに対して,回転楕円体上の三次元長または二次元長を返します.ジオメトリの座標が経度/緯度で,投影変換なしに距離を求める場合に便利です.
float ST_Length_Spheroid(
geometry a_linestring, spheroid a_spheroid)
;
回転楕円体上の長さを返します.ジオメトリの座標が経度/緯度で,投影変換なしに距離を求める場合に便利です.回転楕円体は独立したデータベース型で,次のように構成されています.
SPHEROID[<名称>,<長軸半径>,<扁平率の逆数>]
SPHEROID["GRS_1980",6378137,298.257222101]
![]() | |
MULTILINESTRINGかLINESTRINGでない場合は0が返されます. |
この関数は三次元をサポートします.Zインデクスを削除しません.
SELECT ST_Length_Spheroid( geometry_column, 'SPHEROID["GRS_1980",6378137,298.257222101]' ) FROM geometry_table; SELECT ST_Length_Spheroid( the_geom, sph_m ) As tot_len, ST_Length_Spheroid(ST_GeometryN(the_geom,1), sph_m) As len_line1, ST_Length_Spheroid(ST_GeometryN(the_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 the_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_Length_Spheroid( the_geom, sph_m ) As tot_len, ST_Length_Spheroid(ST_GeometryN(the_geom,1), sph_m) As len_line1, ST_Length_Spheroid(ST_GeometryN(the_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 the_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