Rectifies a raster object using rational polynomial coefficients (RPC) and returns the rectified raster.
Syntax
raster ST_RPCRectify(raster rast,
raster dem DEFAULT NULL,
cstring rectifyOption DEFAULT '{}',
cstring storageOption DEFAULT '{}',
cstring parallelOption DEFAULT '{}')
Parameters
| Parameter | Type | Default | Description |
|---|
rast | raster | — | The raster object to rectify. Must contain RPC information. |
dem | raster | NULL | A digital elevation model (DEM) to reference during rectification. |
rectifyOption | cstring (JSON) | '{}' | Rectification options. |
storageOption | cstring (JSON) | '{}' | Storage options for the output raster. |
parallelOption | cstring (JSON) | '{}' | Parallel processing options. |
Note The input raster object must contain RPC information.
rectifyOption parameters
| Parameter | Type | Default | Description |
|---|
resample | string | Near | The resampling method. Valid values: Near, Average, Cubic, Bilinear. |
outSrid | integer | Same as source | The spatial reference ID (SRID) of the output raster. |
nodataValue | float8 or float8[] | NULL | The nodata value for the output raster. Specify a single value to apply it to all bands, or an array (for example, [0, 0, 0]) with one element per band. If not set, the value defaults to the source raster's nodata value, or 0 if the source has none. |
RPC_DEM_MISSING_VALUE | float8 | 0 | The height value to use when the dem parameter has a nodata value or the pixel falls outside the valid DEM extent. |
storageOption parameters
| Parameter | Type | Default | Description |
|---|
chunking | boolean | Same as source | Specifies whether to store the output raster as chunks. |
chunkdim | string | Same as source | The chunk dimensions. Takes effect only when chunking is true. |
chunktable | string | '' | The name of the chunk table. Set to '' to create a temporary chunk table with a random name in the current session. Temporary tables are deleted when the session ends. Specify a name to persist the output raster beyond the session. If the parallel method does not support anonymous chunk tables, create the chunk table in advance. |
compression | string | Same as source | The compression format. Valid values: NONE, JPEG, ZLIB, PNG, LZO, LZ4, JP2K. |
quality | integer | Same as source | The compression quality. Applies only to JPEG compression. |
interleaving | string | Same as source | The band interleaving method. Valid values: bip (band interleaved by pixel, BIP), bil (band interleaved by line, BIL), bsq (band sequential, BSQ). |
endian | string | Same as source | The byte order of the output raster. Valid values: NDR (little endian), XDR (big endian). |
Examples
CREATE TABLE IF NOT EXISTS raster_table(id integer, rast raster);
-- Load the RPC raster.
INSERT INTO raster_table VALUES(1, ST_ImportFrom('t_chunk', '<RAST_DATA_DIR>/rpc.tif', '{}'));
-- Load the DEM raster.
INSERT INTO raster_table VALUES(2, ST_ImportFrom('t_chunk', '<RAST_DATA_DIR>/rpc_dem.tif', '{}'));
CREATE TABLE raster_result(id integer, rast raster);
-- Rectify without a DEM, using nearest neighbor (NNS) 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 and output in EPSG:32635, using 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;