ST_SetGeoReference — 在一次调用中设置 Georeference 6 地理配准参数。 数字应该用空格分隔。 接受 GDAL 或 ESRI 格式的输入。 默认为 GDAL。
raster ST_SetGeoReference(raster rast, text georefcoords, text format=GDAL);
raster ST_SetGeoReference(raster rast, double precision upperleftx, double precision upperlefty, double precision scalex, double precision scaley, double precision skewx, double precision skewy);
在一次调用中设置 Georeference 6 地理配准参数。 接受“GDAL”或“ESRI”格式的输入。 默认为 GDAL。 如果未提供 6 个坐标,则返回 null。
格式表示的区别如下:
GDAL uses the value order shown below.
scalex skewy skewx scaley upperleftx upperlefty
ESRI uses the value order shown below.
scalex skewy skewx scaley upperleftx + scalex*0.5 upperlefty + scaley*0.5
|
|
|
如果栅格具有数据库外波段,则更改地理参考可能会导致无法正确访问该波段的外部存储数据。 |
增强:2.1.0 添加 ST_SetGeoReference(raster, double precision, ...) 变体
WITH source AS (
SELECT ST_MakeEmptyRaster(5, 5, 0, 0, 1, -1, 0, 0, 0) AS rast
), variants AS (
SELECT 0 AS rid, rast FROM source
UNION ALL
SELECT 1, ST_SetGeoReference(rast, '10 0 0 -10 0.1 0.1', 'GDAL')
FROM source
UNION ALL
SELECT 2, ST_SetGeoReference(rast, '10 0 0 -10 5.1 -4.9', 'ESRI')
FROM source
UNION ALL
SELECT 3, ST_SetGeoReference(rast, 1, 1, 10, -10, 0.001, 0.001)
FROM source
)
SELECT
rid,
round(ST_UpperLeftX(rast)::numeric, 3) AS upperleftx,
round(ST_UpperLeftY(rast)::numeric, 3) AS upperlefty,
ST_ScaleX(rast) AS scalex,
ST_ScaleY(rast) AS scaley,
ST_SkewX(rast) AS skewx,
ST_SkewY(rast) AS skewy
FROM variants
ORDER BY rid;
rid | upperleftx | upperlefty | scalex | scaley | skewx | skewy -----+------------+------------+--------+--------+-------+------- 0 | 0.000 | 0.000 | 1 | -1 | 0 | 0 1 | 0.100 | 0.100 | 10 | -10 | 0 | 0 2 | 0.100 | 0.100 | 10 | -10 | 0 | 0 3 | 1.000 | 1.000 | 10 | -10 | 0.001 | 0.001 (4 rows)