Name

ST_Length — 도형의 기하학적 중심을 반환합니다.

Synopsis

float ST_Length(geometry a_2dlinestring);

float ST_Length(geography geog, boolean use_spheroid = true);

설명

도형의 경우: 도형이 라인스트링, 멀티라인스트링, ST_Curve, ST_MultiCurve일 경우 도형의 2차원 데카르트 길이를 반환합니다. 면 도형의 경우 0을 반환합니다. 면 도형에 대해서는 ST_Perimeter 를 이용하십시오. 도형 유형의 경우, 도형의 공간 참조 시스템이 해당 길이의 측정 단위를 설정합니다.

For geography types: computation is performed using the inverse geodesic calculation. Units of length are in meters. If PostGIS is compiled with PROJ version 4.8.0 or later, the spheroid is specified by the SRID, otherwise it is exclusive to WGS84. If use_spheroid = false, then the calculation is based on a sphere instead of a spheroid.

도형의 경우 이 함수는 현재 ST_Length2D와 동일하지만, 향후 더 높은 차원을 지원하기 위해 변경될 수도 있습니다.

[Warning]

변경 사항: 2.0.0 버전에서 중요한 변경이 이루어졌습니다. 2.0.0 이전 버전에서 이 함수에 폴리곤/멀티폴리곤 유형의 지리형을 입력하면 폴리곤/멀티폴리곤의 둘레를 반환했을 겁니다. 2.0.0 버전부터 도형 습성과 맞추기 위해 0을 반환하도록 변경됐습니다. 폴리곤의 둘레를 원한다면 ST_Perimeter 함수를 이용하십시오.

[Note]

지리형 측정시 기본값은 회전타원체 상의 측정입니다. 더 빠르지만 덜 정확한 구체를 이용하려면 ST_Length(gg,false); 를 쓰십시오.

This method implements the OGC Simple Features Implementation Specification for SQL 1.1. s2.1.5.1

This method implements the SQL/MM specification. SQL-MM 3: 7.1.2, 9.3.4

1.5.0 버전부터 지리형을 지원합니다.

도형 예시

라인스트링의 길이를 피트 단위로 반환합니다. 투영체 EPSG:2249가 매사추세츠 주 피트 단위 평면이기 때문에 피트 단위라는 사실을 주의하십시오.

SELECT ST_Length(ST_GeomFromText('LINESTRING(743238 2967416,743238 2967450,743265 2967450,
743265.625 2967416,743238 2967416)',2249));

st_length
---------
 122.630744000095


--Transforming WGS 84 LineString to Massachusetts state plane meters
SELECT ST_Length(
        ST_Transform(
                ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45, -72.1240 42.45666, -72.123 42.1546)'),
                26986
        )
);

st_length
---------
34309.4563576191
                        

지리형 예시

WGS84 지리형 라인의 길이를 반환합니다.

-- the default calculation uses a spheroid
SELECT ST_Length(the_geog) As length_spheroid,  ST_Length(the_geog,false) As length_sphere
FROM (SELECT ST_GeographyFromText(
'SRID=4326;LINESTRING(-72.1260 42.45, -72.1240 42.45666, -72.123 42.1546)') As the_geog)
 As foo;

 length_spheroid  |  length_sphere
------------------+------------------
 34310.5703627288 | 34346.2060960742