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
| Parameter | Description |
|---|---|
rast | The raster object to rectify. Must contain RPC information. |
dem | A digital elevation model (DEM) raster used during rectification. Default: NULL. |
rectifyOption | Rectification options as a JSON string. See rectifyOption parameters. |
storageOption | Storage options for the output raster as a JSON string. See storageOption parameters. |
parallelOption | Parallel 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
| Parameter | Type | Default | Description |
|---|---|---|---|
resample | string | Near | Resampling method. See the table below for available methods and their quality trade-offs. |
outSrid | integer | Same as source | Spatial reference identifier (SRID) of the output raster. |
nodataValue | float8 or float8[] | NULL | Nodata 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_VALUE | float8 | 0 | Height 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
| Value | Description |
|---|---|
Near | Nearest neighbor resampling. Fastest method, lowest interpolation quality. Suitable for categorical or thematic rasters where preserving exact pixel values matters. |
Bilinear | Bilinear resampling. Balances speed and output quality. A good default for continuous data. |
Cubic | Cubic resampling. Higher output quality than bilinear at the cost of additional processing time. |
Average | Average resampling. Useful for downsampling. |
storageOption parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
chunking | boolean | Same as source | Specifies whether to store the output raster in chunks. |
chunkdim | string | Same as source | Chunk dimensions, for example (256,256,1). Takes effect only when chunking is true. |
chunktable | string | '' | 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. |
compression | string | Same as source | Compression format for the output raster. Valid values: NONE, JPEG, ZLIB, PNG, LZO, LZ4, JP2K. |
quality | integer | Same as source | Compression quality level. Applies to JPEG format only. |
interleaving | string | Same as source | Band interleaving format. Valid values: bip (band interleaved by pixel), bil (band interleaved by line), bsq (band sequential). |
endian | string | Same as source | Byte order of the output raster. Valid values: NDR (little-endian), XDR (big-endian). |
parallelOption parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
parallel | integer | — | Number 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;