ST_Resize — 将栅格大小调整为新的宽度/高度
raster
ST_Resize
(
raster
rast
, integer
width
, integer
height
, text
algorithm=NearestNeighbor
, double precision
maxerr=0.125
)
;
raster
ST_Resize
(
raster
rast
, double precision
percentwidth
, double precision
percentheight
, text
algorithm=NearestNeighbor
, double precision
maxerr=0.125
)
;
raster
ST_Resize
(
raster
rast
, text
width
, text
height
, text
algorithm=NearestNeighbor
, double precision
maxerr=0.125
)
;
将栅格大小调整为新的宽度/高度。新的宽度/高度可以用精确的像素数或栅格宽度/高度的百分比来指定。新栅格的范围将与提供的栅格的范围相同。
使用NearestNeighbor(英式或美式拼写)、双线性、立方、立方样条线或Lanczos重采样算法计算新的像素值。默认值为NearestNeighbor,它是最快的,但结果是最差的插值。
变体1期望输出栅格的实际宽度/高度。
变体2需要介于零(0)和一(1)之间的十进制值,表示输入栅格的宽度/高度的百分比。
变量3采用输出栅格的实际宽度/高度或文本百分比(“20%”),表示输入栅格的宽度/高度的百分比。
可用性:2.1.0需要GDAL 1.6.1+
WITH foo AS(
SELECT
1 AS rid,
ST_Resize(
ST_AddBand(
ST_MakeEmptyRaster(1000, 1000, 0, 0, 1, -1, 0, 0, 0)
, 1, '8BUI', 255, 0
)
, '50%', '500') AS rast
UNION ALL
SELECT
2 AS rid,
ST_Resize(
ST_AddBand(
ST_MakeEmptyRaster(1000, 1000, 0, 0, 1, -1, 0, 0, 0)
, 1, '8BUI', 255, 0
)
, 500, 100) AS rast
UNION ALL
SELECT
3 AS rid,
ST_Resize(
ST_AddBand(
ST_MakeEmptyRaster(1000, 1000, 0, 0, 1, -1, 0, 0, 0)
, 1, '8BUI', 255, 0
)
, 0.25, 0.9) AS rast
), bar AS (
SELECT rid, ST_Metadata(rast) AS meta, rast FROM foo
)
SELECT rid, (meta).* FROM bar
rid | upperleftx | upperlefty | width | height | scalex | scaley | skewx | skewy | srid | numbands
-----+------------+------------+-------+--------+--------+--------+-------+-------+------+----------
1 | 0 | 0 | 500 | 500 | 1 | -1 | 0 | 0 | 0 | 1
2 | 0 | 0 | 500 | 100 | 1 | -1 | 0 | 0 | 0 | 1
3 | 0 | 0 | 250 | 900 | 1 | -1 | 0 | 0 | 0 | 1
(3 rows)