次の方法で共有


st_force2d 関数

適用対象:はい Databricks Runtime 18.1 以降とマークされているチェック

Important

この機能は パブリック プレビュー段階です

入力 GEOGRAPHY または GEOMETRY 値の 2D プロジェクションを返します。

構文

st_force2d ( geoExpr )

引数

  • geoExpr: GEOGRAPHY または GEOMETRY の値。

返品

入力値の 2D プロジェクションを表す GEOGRAPHY 型または GEOMETRY型の値。

出力 GEOGRAPHY または GEOMETRY 値の SRID 値は、入力値の SRID 値と等しくなります。

入力がNULL場合、この関数はNULLを返します。

メモ

入力に Z 座標または M 座標がある場合、これらは出力で除外されます。

入力が既に 2D の場合、関数はそれを変更せずに返します。

例示

-- Drops the M coordinate from a point geography.
> SELECT st_astext(st_force2d(st_geogfromtext('POINT M (1 2 3)')));
  POINT(1 2)
-- Drops Z and M coordinates from a multipoint geography.
> SELECT st_astext(st_force2d(st_geogfromtext('MULTIPOINT ZM (EMPTY,0 0 10 20, 1 1 11 21)')));
  MULTIPOINT(EMPTY,(0 0),(1 1))
-- Drops the Z coordinate from a polygon geography.
> SELECT st_astext(st_force2d(st_geogfromtext('POLYGON Z ((0 0 2,1 0 3,0 1 4,0 0 5))')));
  POLYGON((0 0,1 0,0 1,0 0))
-- Drops the Z coordinate from a point geometry.
> SELECT st_astext(st_force2d(st_geomfromtext('POINT Z (1 2 3)')));
  POINT(1 2)
-- Drops Z and M coordinates from a linestring geometry.
> SELECT st_astext(st_force2d(st_geomfromtext('LINESTRING ZM (0 0 10 20, 1 1 11 21)')));
  LINESTRING(0 0,1 1)
-- Returns the input 2D geometry as is.
> SELECT st_astext(st_force2d(st_geomfromtext('POINT(1 2)')));
  POINT(1 2)
-- Preserves the SRID of the input geography.
> SELECT st_srid(st_force2d(st_geogfromtext('POINT(1 2)')));
  4326
-- Preserves the SRID of the input geometry.
> SELECT st_srid(st_force2d(st_geomfromtext('POINT(1 2)', 4326)));
  4326
-- Returns NULL if the input is NULL.
> SELECT st_force2d(NULL);
   NULL