メインコンテンツへスキップ

Geometry

Geometry 関数では、POLYGON、LINESTRING、MULTIPOLYGON、MULTILINESTRING、RING、POINT などの幾何型の周長と面積を計算できます。ジオメトリは Geometry 型で使用します。入力値が NULL の場合、以下のすべての関数は 0 を返します。

perimeterCartesian

デカルト座標系 (平面) における、指定されたGeometryオブジェクトの周長を計算します。 構文
perimeterCartesian(geom)
引数
  • geom — Geometry オブジェクト。Geometry
戻り値
  • 数値 — 座標系の単位で表したオブジェクトの周長。Float64
Query
CREATE TABLE IF NOT EXISTS geo_dst (geom Geometry) ENGINE = Memory();
INSERT INTO geo_dst SELECT readWKT('POLYGON((0 0,1 0,1 1,0 1,0 0))');
SELECT perimeterCartesian(geom) FROM geo_dst;
Response
┌─perimeterCartesian(geom)─┐
│ 4.0                      │
└──────────────────────────┘

areaCartesian

指定されたGeometryオブジェクトの面積をデカルト座標系で計算します。 構文
areaCartesian(geom)
引数
  • geom — Geometryオブジェクト。Geometry
戻り値
  • 数値 — オブジェクトの面積 (座標系の単位) 。Float64
Query
CREATE TABLE IF NOT EXISTS geo_dst (geom Geometry) ENGINE = Memory();
INSERT INTO geo_dst SELECT readWKT('POLYGON((0 0,1 0,1 1,0 1,0 0))');
SELECT areaCartesian(geom) FROM geo_dst;
Response
┌─areaCartesian(geom)─┐
│ -1                  │
└─────────────────────┘

perimeterSpherical

球面上の Geometry オブジェクトの周長を計算します。 構文
perimeterSpherical(geom)
引数
  • geom — Geometryオブジェクト。Geometry
戻り値
Query
CREATE TABLE IF NOT EXISTS geo_dst (geom Geometry) ENGINE = Memory();
INSERT INTO geo_dst SELECT readWKT('LINESTRING(0 0,1 0,1 1,0 1,0 0)');
SELECT perimeterSpherical(geom) FROM geo_dst;
Response
┌─perimeterSpherical(geom)─┐
│ 0                        │
└──────────────────────────┘

areaSpherical

球面上のGeometryオブジェクトの面積を計算します。 構文
areaSpherical(geom)
引数 戻り値
Query
CREATE TABLE IF NOT EXISTS geo_dst (geom Geometry) ENGINE = Memory();
INSERT INTO geo_dst SELECT readWKT('POLYGON((0 0,1 0,1 1,0 1,0 0))');
SELECT areaSpherical(geom) FROM geo_dst;
Response
┌─areaSpherical(geom)────┐
│ -0.0003046096848622019 │
└────────────────────────┘
最終更新日 2026年6月12日