All Products
Search
Document Center

ApsaraDB RDS:ST_Resize

Last Updated:Mar 28, 2026

Resizes the pixel range of a raster object without changing its geospatial extent.

Syntax

raster ST_Resize(raster rast,
           integer outWidth,
           integer outHeight,
           cstring processExpr default '',
           cstring storageOption default '')

Parameters

ParameterDescription
rastThe raster object to resize.
outWidthThe width of the output raster object, in pixels.
outHeightThe height of the output raster object, in pixels.
processExprA JSON string that controls pixel resampling and nodata value handling.
storageOptionA JSON string that controls how the output raster object is stored.

processExpr fields

Each key-value pair in the processExpr JSON string maps to a field described below.

FieldTypeDefaultDescription
resampletextNearThe resampling method. Valid values: Near, Average, Cubic, Bilinear.
nodataBooleanfalseSpecifies whether to treat nodata values in the source raster object as valid. If set to true, pixels with nodata values are not resampled. If set to false, pixels with nodata values are resampled.
nodataValuefloat8 | float8[]NULLThe nodata value to assign to bands in the output raster object. Specify one value to apply it to all bands, or specify one value per band. The number of values must match the number of bands.
Note Set nodata to false and omit nodataValue if the source raster object has no pixels with nodata values. Otherwise, image artifacts may occur.

storageOption fields

FieldTypeDefaultDescription
chunkingBooleanSame as sourceSpecifies whether to store the output raster object as chunks.
chunkdimStringSame as sourceThe chunk dimensions. Takes effect only when chunking is true.
chunktableString'' (empty string)The name of the chunk table. If set to NULL or an empty string, the output is stored in a temporary chunk table with a random name, valid for the current session only. To persist the output, specify a permanent chunk table name.
compressionStringSame as sourceThe compression format. Valid values: None, JPEG, Zlib, PNG, LZO, LZ4.
qualityIntegerSame as sourceThe JPEG image quality. Takes effect only when compression is JPEG.
interleavingStringSame as sourceThe interleaving type. Valid values: bip (band interleaved by pixel, BIP), bil (band interleaved by line, BIL), bsq (band sequential, BSQ).
endianStringSame as sourceThe byte order. Valid values: NDR (little-endian), XDR (big-endian).
Note If chunktable is NULL or an empty string, the output is stored in a temporary chunk table that is deleted when the current session ends. Specify a chunk table name to save the output permanently.

Examples

CREATE TABLE IF NOT EXISTS datasource_table(id integer, rast raster);
INSERT INTO datasource_table VALUES(1, ST_ImportFrom('rbt','$(RAST_DATA_DIR)/512_512_1_bsq_8u_geo.tif', '{}'));

Method 1: Specify a permanent chunk table

Use a named chunktable to persist the output raster object.

CREATE TABLE rat_resize_result(id integer, rast raster);

-- No nodata field specified
INSERT INTO rat_resize_result(id, rast)
SELECT 10, ST_Resize(rast, 1024, 1024,
  '{"resample":"Near","nodata":false}',
  '{"chunking":true,"chunkdim":"(256,256,1)","compression":"none","interleaving":"bsq","chunktable":"result_rbt"}')
FROM datasource_table
WHERE id = 1;

-- Single nodata value applied to all bands; nodata pixels are not resampled
INSERT INTO rat_resize_result(id, rast)
SELECT 11, ST_Resize(rast, 1024, 1024,
  '{"resample":"Near","nodata":true,"nodatavalue":255}',
  '{"chunking":true,"chunkdim":"(256,256,1)","compression":"none","interleaving":"bsq","chunktable":"result_rbt"}')
FROM datasource_table
WHERE id = 1;

-- Multiple nodata values, one per band
INSERT INTO rat_resize_result(id, rast)
SELECT 12, ST_Resize(rast, 1024, 1024,
  '{"resample":"Near","nodata":false,"nodatavalue":[255,255,255]}',
  '{"chunking":true,"chunkdim":"(256,256,1)","compression":"none","interleaving":"bsq","chunktable":"result_rbt"}')
FROM datasource_table
WHERE id = 1;

Method 2: Use a temporary chunk table

Omit chunktable to store the output in a session-scoped temporary table. The result is available for nested computations in the current session and is deleted when the session ends.

CREATE TEMP TABLE rat_resize_result_temp(id integer, rast raster);

INSERT INTO rat_resize_result_temp(id, rast)
SELECT 1, ST_Resize(rast, 1024, 1024,
  '{"resample":"Near","nodata":false,"nodataValue":[255,255,255]}',
  '{"chunking":true,"chunkdim":"(256,256,1)","compression":"none","interleaving":"bsq"}')
FROM datasource_table
WHERE id = 1;