This topic describes the ST_SubRaster function. This function transforms a pyramid level or band of a raster object.

Syntax

raster ST_SubRaster(raster raster_obj ,
           integer pyramidLevel default 0,
           cstring bands default '',  /* All bands */
           cstring storageOption  default '')

Parameters

Parameter Description
raster_obj The original raster object whose pyramid level or band you want to transform.
pyramidLevel The pyramid level that you want to transform.
bands The band that you want to transform. The value of this field can be an array of integers or an integer range starting from 0. Examples: "0-2" and "1,2,3'. Default value: null string (''). The default value specifies to transform all bands.
storageOption The JSON string that specifies how to store the new raster object.

The following table describes fields in the storageOption parameter.

Field Description Type Default value Setting notes
chunking Specifies whether to store the new raster object as chunks. Boolean Same as the original raster object N/A.
chunkdim The dimensions used to store the new raster object as chunks. String Same as the original raster object This field only takes effect when the chunking field is set to true.
chunktable The name of the chunk table. String Null string ('') By default, a temporary chunk table with a random name is generated to store data. This temporary chunk table is only valid in the current session. To save the new raster object permanently, you must specify you want to create a permanent chunk table in the chunktable field.
compression The format used for image compression. String Same as the original raster object Six compression formats are supported: None, JPEG, Zlib, PNG, LZO, and LZ4.
quality The image quality of the new raster object. Integer Same as the original raster object This field only takes effect in JPEG format.
interleaving The interleaving type of the new raster object. String Same as the original raster object Valid values:
  • bip: band interleaved by pixel (BIP)
  • bil: band interleaved by line (BIL)
  • bsq: band sequential (BSQ)
endian The endian format of the new raster object. String Same as the original raster object Valid values:
  • NDR: specifies little endian format.
  • XDR: specifies big endian format.

Examples

SELECT ST_SubRaster(rast, 1, '0-2', '{"chunktable":"chunk_table", "chunking":true}')
FROM raster_sub
WHERE id=1;