All Products
Search
Document Center

PolarDB:ST_RPCRectify

Last Updated:Mar 28, 2026

Rectifies a raster object based on rational polynomial coefficients (RPC) parameters and returns the rectified raster object.

Syntax

raster ST_RPCRectify(raster rast,
                     raster dem DEFAULT NULL,
                     cstring rectifyOption DEFAULT '{}',
                     cstring storageOption DEFAULT '{}',
                     cstring parallelOption DEFAULT '{}')

Parameters

ParameterDescription
rastThe raster object to rectify. Must contain RPC information.
demA digital elevation model (DEM) raster used during rectification. Default: NULL.
rectifyOptionRectification options as a JSON string. See rectifyOption parameters.
storageOptionStorage options for the output raster as a JSON string. See storageOption parameters.
parallelOptionParallel processing options as a JSON string. See parallelOption parameters.

Description

ST_RPCRectify corrects geometric distortions in satellite and aerial imagery using the RPC model embedded in the raster object.

The input raster object must contain RPC information.

rectifyOption parameters

ParameterTypeDefaultDescription
resamplestringNearResampling method. See the table below for available methods and their quality trade-offs.
outSridintegerSame as sourceSpatial reference identifier (SRID) of the output raster.
nodataValuefloat8 or float8[]NULLNodata value for the output raster bands. Specify a single value to apply to all bands, or an array (for example, [0, 0, 0]) with one element per band. If not set, the value is inherited from the source raster; if the source has no nodata value, it defaults to 0.
RPC_DEM_MISSING_VALUEfloat80Height value used when the DEM has a nodata pixel at the sample location, or when the sample coordinate falls outside the DEM's spatial coverage.

Resampling methods

ValueDescription
NearNearest neighbor resampling. Fastest method, lowest interpolation quality. Suitable for categorical or thematic rasters where preserving exact pixel values matters.
BilinearBilinear resampling. Balances speed and output quality. A good default for continuous data.
CubicCubic resampling. Higher output quality than bilinear at the cost of additional processing time.
AverageAverage resampling. Useful for downsampling.

storageOption parameters

ParameterTypeDefaultDescription
chunkingbooleanSame as sourceSpecifies whether to store the output raster in chunks.
chunkdimstringSame as sourceChunk dimensions, for example (256,256,1). Takes effect only when chunking is true.
chunktablestring''Name of the chunk table. If set to an empty string '', a temporary chunk table with a random name is created for the current session and deleted when the session ends. To persist the output raster beyond the session, specify a table name. If the parallel method does not support anonymous chunk tables, create the chunk table in advance.
compressionstringSame as sourceCompression format for the output raster. Valid values: NONE, JPEG, ZLIB, PNG, LZO, LZ4, JP2K.
qualityintegerSame as sourceCompression quality level. Applies to JPEG format only.
interleavingstringSame as sourceBand interleaving format. Valid values: bip (band interleaved by pixel), bil (band interleaved by line), bsq (band sequential).
endianstringSame as sourceByte order of the output raster. Valid values: NDR (little-endian), XDR (big-endian).

parallelOption parameters

ParameterTypeDefaultDescription
parallelintegerNumber of parallel workers for the rectification job. For example, {"parallel": 8} runs the job with 8 parallel workers.

Examples

Both examples use the same source tables. The RPC raster and the DEM are loaded into raster_table, and results are written to raster_result.

CREATE TABLE IF NOT EXISTS raster_table (id integer, rast raster);

-- Load the RPC raster data.
INSERT INTO raster_table VALUES (1, ST_ImportFrom('t_chunk', '<RAST_DATA_DIR>/rpc.tif', '{}'));

-- Load the DEM data.
INSERT INTO raster_table VALUES (2, ST_ImportFrom('t_chunk', '<RAST_DATA_DIR>/rpc_dem.tif', '{}'));

CREATE TABLE raster_result (id integer, rast raster);

Replace <RAST_DATA_DIR> with the directory path where your raster files are stored.

Rectify without a DEM

Uses nearest neighbor resampling.

INSERT INTO raster_result (id, rast)
SELECT 10, ST_RPCRectify(
    rast,
    NULL,
    '{"resample": "Near"}',
    '{"chunking": true, "chunkdim": "(256,256,1)", "interleaving": "bsq", "chunktable": "t_chunk"}'
)
FROM raster_table
WHERE id = 1;

Rectify with a DEM, output SRID, and parallel processing

Provides a DEM for improved height accuracy, reprojects the output to EPSG:32635 (WGS 84 / UTM zone 35N), and runs with 8 parallel workers.

INSERT INTO raster_result (id, rast)
SELECT 11, ST_RPCRectify(
    rast,
    (SELECT rast FROM raster_table WHERE id = 2),
    '{"resample": "Near", "outSrid": 32635}',
    '{"chunking": true, "chunkdim": "(256,256,1)", "interleaving": "bsq", "chunktable": "t_chunk"}',
    '{"parallel": 8}'
)
FROM raster_table
WHERE id = 1;