ST_Resize
Name
ST_Resize — Resize a raster to a new width/height
Synopsis
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
)
;
Description
Resize a raster to a new width/height. The new width/height can be specified in exact number of pixels or a percentage of the raster's width/height. The extent of the the new raster will be the same as the extent of the provided raster.
New pixel values are computed using the NearestNeighbor (english or american spelling), Bilinear, Cubic, CubicSpline or Lanczos resampling algorithm. The default is NearestNeighbor which is the fastest but results in the worst interpolation.
Variant 1 expects the actual width/height of the output raster.
Variant 2 expects decimal values between zero (0) and one (1) indicating the percentage of the input raster's width/height.
Variant 3 takes either the actual width/height of the output raster or a textual percentage ("20%") indicating the percentage of the input raster's width/height.
Availability: 2.1.0 Requires GDAL 1.6.1+
Examples
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)