ST_BuildPyramid

更新时间:
复制 MD 格式

Builds a pyramid for a raster object to enable multi-resolution rendering and efficient spatial queries.

Syntax

raster ST_BuildPyramid(raster source,
                       integer pyramidLevel default -1,
                       ResampleAlgorithm algorithm default 'Near',
                       cstring chunkTableName default '',
                       cstring storageOption default '{}',
                       cstring buildOption default '{}');

Parameters

ParameterDescription
sourceThe raster object to build the pyramid for.
pyramidLevelThe number of pyramid levels to build. Set to -1 to build the maximum number of levels. Default value: -1.
algorithmThe resampling algorithm used when downsampling raster data for each pyramid level. Valid values: Near, Average, Bilinear, Cubic. Default value: Near.
chunkTableNameThe name of the chunk table to store pyramid data. Takes effect only when the raster object is stored in an Object Storage Service (OSS) bucket.
storageOptionA JSON string that specifies chunk storage settings for the pyramid. Takes effect only when the raster object is stored in an OSS bucket. For details, see the storageOption parameters table below.
buildOptionA JSON string that specifies pyramid build settings. PolarDB supports the parallel parameter, which sets the degree of parallelism as an INTEGER from 1 to 64. If not set, the value of the GUC parameter ganos.parallel.degree is used.

storageOption parameters

ParameterTypeDescription
chunkdimstringThe chunk dimensions in (w, h, b) format. Defaults to the chunk size derived from the original image data.
interleavingstringThe band interleaving method. Valid values: bip (band interleaved by pixel), bil (band interleaved by line), bsq (band sequential, default), auto (determined by the function).
compressionstringThe compression format for pyramid data. Valid values: none, jpeg, zlib, png, lzo, LZ4 (default), zstd, snappy, jp2k.
qualityintegerThe compression quality. Applies only to JPEG and JPEG 2000 (jp2k) compression. Valid values: 1–99. Default value: 75.

Usage notes

  • GPU acceleration: ST_BuildPyramid supports GPU-accelerated computing. In environments with active GPUs, Ganos enables GPU acceleration automatically.

  • Parallel execution and transactions: If you run threads in parallel to create the pyramid, transactions are not supported. If pyramid building fails or you need to roll back, call ST_deletePyramid to remove the incomplete pyramid.

Examples

Example 1: Build a pyramid with default settings

DO $$
declare
    rast raster;
begin
    select raster_obj into rast from raster_table where id = 1;
    rast = st_buildpyramid(rast);
    update raster_table set raster_obj = rast where id = 1;
end;
$$ LANGUAGE 'plpgsql';

Example 2: Build a pyramid and store data in a specified chunk table

DO $$
declare
    rast raster;
begin
    select raster_obj into rast from raster_table where id = 1;
    rast = st_buildpyramid(rast, 'chunk_table');
    update raster_table set raster_obj = rast where id = 1;
end;
$$ LANGUAGE 'plpgsql';

What's next