名前

ST_LengthSpheroid — 回転楕円体面上の経度緯度のジオメトリの2次元または3次元の長さ/周長を返します。

概要

float ST_LengthSpheroid(geometry a_geometry, spheroid a_spheroid);

説明

回転楕円体面のジオメトリーの周囲長を計算します。ジオメトリーの座標が経度/緯度で、投影せずに周囲長を求めたい場合に使います。回転楕円体面は次のようなテキスト値で指定します:

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

例:

SPHEROID["GRS_1980",6378137,298.257222101]

Availability: 1.2.2

Changed: 2.2.0 これより前の版では、これはST_Length_Spheroidと呼ばれ、ST_3DLength_Spheroidという別名を持っていました。

この関数は3次元に対応し、Z値を削除しません。

Measure a table geometry directly on a spheroid when the coordinates are stored in longitude and latitude.

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

This example measures a 2D MultiLineString and each component separately on the same spheroid.

Code
WITH sample AS (
  SELECT 'MULTILINESTRING((-118.584 38.374,-118.583 38.5),
          (-71.05957 42.3589,-71.061 43))'::geometry AS geom,
         CAST('SPHEROID["GRS_1980",6378137,298.257222101]' AS spheroid) AS sph_m
)
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 sample;
出力:
tot_len      |    len_line1     |    len_line2
------------------+------------------+------------------
 85204.52077117894 | 13986.87252824332 | 71217.64824293563
Figure
Geometry figure for visual-st-length-spheroid-01

This example uses 3D input; Z contributes to the measured result.

Code
WITH sample AS (
  SELECT 'MULTILINESTRING((-118.584 38.374 20,-118.583 38.5 30),
          (-71.05957 42.3589 75,-71.061 43 90))'::geometry AS geom,
         CAST('SPHEROID["GRS_1980",6378137,298.257222101]' AS spheroid) AS sph_m
)
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 sample;
出力:
tot_len      |    len_line1    |    len_line2
------------------+-----------------+------------------
 85204.52592562366 | 13986.876103023424 | 71217.64982260024
Figure
Geometry figure for visual-st-length-spheroid-02

関連情報

ST_GeometryN, ST_Length