st_setsrid function

适用于:勾选为是 Databricks SQL 勾选为是 Databricks 运行时 17.1 及以上 勾选 是 Lakehouse//RT

Important

支持 GEOGRAPHY 值以 公共预览版提供。 对 GEOMETRY 值的支持 已正式发布。

注释

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

返回一个新的 GEOGRAPHY 或 GEOMETRY 值,其 SRID 是指定的 SRID 值。

Syntax

st_setsrid ( geo, srid )

Arguments

  • geo: A GEOGRAPHY 或 GEOMETRY value。
  • srid:几何体的新SRID值。

Returns

一个GEOGRAPHY或GEOMETRY类型的值,表示某个新地理或几何图形值,其 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)