ST_MosaicFrom

更新时间:
复制 MD 格式

Mosaics an array of raster objects into a single new raster.

Syntax

raster ST_MosaicFrom(raster source[], cstring chunkTableName);

Parameters

ParameterDescription
sourceAn array of raster objects to combine.
chunkTableNameThe name of the chunk table that stores the output raster. The name must follow the table naming conventions of ApsaraDB RDS for PostgreSQL.

Description

ST_MosaicFrom mosaics multiple raster objects into a single output raster and stores the result in the specified chunk table.

All input rasters must meet the following requirements:
All rasters must have the same number of bands.
All rasters must be georeferenced, or none of them must be georeferenced. If all rasters are georeferenced, the mosaic uses world coordinates (geographic coordinates).
Rasters can have different pixel types.
If world coordinates are used, all rasters must share the same spatial reference system identifier (SRID) and affine parameters.

Examples

Example: Mosaic rasters from a table query

This example selects rasters with id < 5 from raster_table, mosaics them into a new raster stored in chunk_table_mosaic, and inserts the result with id = 10.

DO $$
DECLARE
    rasts raster[];
    rast_mosaic raster;
BEGIN
    rasts = Array(SELECT raster_obj FROM raster_table WHERE id < 5 ORDER BY id);
    rast_mosaic = ST_MosaicFrom(rasts, 'chunk_table_mosaic');
    INSERT INTO raster_table VALUES(10, rast_mosaic);
END;
$$ LANGUAGE 'plpgsql';