Rectifies a raster object based on rational polynomial coefficients (RPC) parameters and returns the rectified raster.
Syntax
raster ST_RPCRectify(raster rast,
raster dem DEFAULT NULL,
cstring rectifyOption DEFAULT '{}',
cstring storageOption DEFAULT '{}',
cstring parallelOption DEFAULT '{}')Prerequisites
The raster object must contain RPC information.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
rast | raster | — | The raster object to rectify. |
dem | raster | NULL | A digital elevation model (DEM) referenced during rectification. Default value: NULL. |
rectifyOption | cstring | '{}' | Rectification options as a JSON string. |
storageOption | cstring | '{}' | Output storage options as a JSON string. |
parallelOption | cstring | '{}' | Parallel processing options as a JSON string. |
rectifyOption parameters
| Parameter | Type | Default | Notes |
|---|---|---|---|
resample | string | 'Near' | Resampling method. Valid values: Near, Average, Cubic, Bilinear. |
outSrid | integer | Same as source | Spatial reference identifier (SRID) for the output raster. |
nodataValue | float8 or float8[] | NULL | Nodata value for the output raster bands. Specify a single value to apply it to all bands, or an array (e.g., [0, 0, 0]) with one element per band. If omitted, the value is inherited from the source raster; if the source has no nodata value, defaults to 0. |
RPC_DEM_MISSING_VALUE | float8 | 0 | Height value used when the DEM has a nodata value at the sample point, or when the sample coordinate falls outside the DEM extent. |
storageOption parameters
| Parameter | Type | Default | Notes |
|---|---|---|---|
chunking | boolean | Same as source | Whether to store the output as chunks. |
chunkdim | string | Same as source | Chunk dimensions. Takes effect only when chunking is true. |
chunktable | string | '' | Name of the chunk table. If set to '', 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, specify a table name. If the parallel method does not support chunk tables created by anonymous users, create the chunk table before calling the function. |
compression | string | Same as source | Compression format. Valid values: NONE, JPEG, ZLIB, PNG, LZO, LZ4, JP2K. |
quality | integer | Same as source | Compression quality. Takes effect only with JPEG compression. |
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). |
Examples
The following examples use a table that stores both the source RPC raster and the DEM. Set up the tables first:
CREATE TABLE IF NOT EXISTS raster_table (id integer, rast raster);
CREATE TABLE raster_result (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', '{}'));Replace <RAST_DATA_DIR> with the directory path containing your raster files.
Rectify without a DEM
Use nearest neighbor resampling (NNS method) without specifying a DEM:
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 and parallel processing
Use nearest neighbor resampling (NNS method) with a DEM and parallel processing:
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;