st_setsrid 函数

适用于:检查标记为“是”的 Databricks SQL 检查标记为“是”是 Databricks Runtime 17.1 及更高版本

Important

此功能目前以公共预览版提供。

注释

此功能在 Databricks SQL 经典仓库上不可用。 若要详细了解 Databricks SQL 仓库,请参阅 SQL 仓库类型

返回一个新的 GEOGRAPHYGEOMETRY 值,其 SRID 是指定的 SRID 值。

Syntax

st_setsrid ( geo, srid )

Arguments

  • geoGEOGRAPHYGEOMETRY值。
  • srid:几何图形的新 SRID 值。

Returns

一个GEOGRAPHYGEOMETRY类型的值,表示某个新地理或几何图形值,其 SRID 为指定的 SRID 值。

如果任何输入为NULL,该函数将返回NULL

Examples

-- Sets SRID to 3857 and returns the new SRID value.
> SELECT st_srid(st_setsrid(ST_GeomFromText('POINT(4 5)', 4326), 3857));
  3857

-- Returns the original geometry with the new SRID value.
> SELECT st_asewkt(st_setsrid(st_geomfromtext('POINT(1 2)'), 4326));
  SRID=4326;POINT(1 2)

-- Returns the original geography with the new SRID value.
> SELECT st_asewkt(st_setsrid(to_geography('POINT(1 2)'), 4326));
  SRID=4326;POINT(1 2)

-- When invoking st_setsrid with a literal for the SRID value, the output geography type inherits the SRID value.
> SELECT typeof(st_setsrid(to_geography('POINT(1 2)'), 4326));
  geography(4326)

-- When invoking st_setsrid with a literal for the SRID value, the output geometry type inherits the SRID value.
> SELECT typeof(st_setsrid(to_geometry('POINT(1 2)'), 3857));
  geometry(3857)