Interpolates a collection of points in the (x,y,z) format and returns a new raster object.
Syntax
raster ST_InterpolateRaster(
geometry input_points,
integer width,
integer height,
cstring interpolateOptions,
cstring storageOptions);Parameters
Parameter | Description |
input_points | The collection of interpolation points. |
width | The number of columns in the raster. |
height | The number of rows in the raster. |
interpolateOptions | A JSON-formatted string that describes the details of the spatial interpolation algorithm. |
storageOption | A JSON-formatted string that describes the chunk storage information for the raster object. |
The interpolateOptions parameter supports the following arguments:
Argument | Description | Type | Default value | Notes |
method | The interpolation method. | string | IDW | Only Inverse Distance Weighting (IDW) interpolation is supported. |
radius | The search radius. | double | 0.0 | If this argument is set to 0, the search radius is calculated based on the number of input points and the area size. |
power | The interpolation weight. | double | 2.0 | None. |
max_points | The maximum number of points. | integer | 10 | The value must be greater than the value of `min_points`. |
min_points | The minimum number of points. | integer | 2 | None. |
nodata | The no-data value. | double | 0.0 | None. |
parallel | The degree of parallelism. | integer | 1 | None. |
The storageOption parameter supports the following arguments:
Argument | Description | Type | Format | Default value | Notes |
chunkdim | The dimension of the chunk. | string | (w, h, b) | The chunk size is read from the original image. | None. |
chunktable | The name of the chunk table to write to. | string | None. | None. | If you do not specify this argument, a temporary table is created. |
celltype | The pixel type. | string | None. | 16BUI | The pixel type of the raster object. Valid values:
|
Examples
-- A common example
SELECT ST_InterpolateRaster(
st_collect(ST_MakePoint(st_x(geom),st_y(geom),value)),
256,
256,
'{"method":"IDW","radius":"3.0","max_points":"4","min_points":"1"}',
'{"chunktable":"rbt","celltype":"8bui"}')
FROM point_table;
st_interpolateraster
---------------------
{"attributes":{"id":"f54cff0a-cca4-4e51-ac11-7aa5a3c9d9b6","name":"","type":"normal","version":1.1,"storage":{"mode":"internal","location":"rbt","md5":"","endian":"ndr","compress":"lz4","compressQuality":75,"fileSystem":"null","chunking":{"enable":true,"chunkHeight":256,"chunkWidth":256,"chunkBand":1,"rowChunksDimension":1,"columnChunksDimension":1,"bandChunksDimension":1},"cellType":"8bui","interleaving":"bsq"},"description":"","width":256,"height":256,"bands":1,"pyramid":{"resample":"near","level":0,"table":""},"overview":{"table":"","column":"","pyramidLevel":1},"referenceOriginPoint":{"type":"Raster","ulp":{"row":0,"column":0,"band":0},"rrp":{"row":0,"column":0,"band":0},"wrp":{"x":0,"y":0,"z":0}}},"spatialReference":{"valid":true,"srid":0,"refLocation":"center","affline":{"upperleftx":0.0,"upperlefty":2.0,"scalex":0.0078125,"scaley":-0.0078125,"skewx":0.0,"skewy":0.0},"gcps":{"count":0}}}
-- Specify the parallel argument
SELECT ST_InterpolateRaster(
st_collect(ST_MakePoint(st_x(geom),st_y(geom),value)),
256,
256,
'{"radius":"2.0","max_points":"4","min_points":"1","parallel":"4"}',
'{"chunktable":"rbt","celltype":"8bui"}')
FROM point_table;
st_interpolateraster
---------------------
{"attributes":{"id":"b769c306-4416-4e31-9e60-d2b847642190","name":"","type":"normal","version":1.1,"storage":{"mode":"internal","location":"rbt","md5":"","endian":"ndr","compress":"lz4","compressQuality":75,"fileSystem":"null","chunking":{"enable":true,"chunkHeight":256,"chunkWidth":256,"chunkBand":1,"rowChunksDimension":1,"columnChunksDimension":1,"bandChunksDimension":1},"cellType":"8bui","interleaving":"bsq"},"description":"","width":256,"height":256,"bands":1,"pyramid":{"resample":"near","level":0,"table":""},"overview":{"table":"","column":"","pyramidLevel":1},"referenceOriginPoint":{"type":"Raster","ulp":{"row":0,"column":0,"band":0},"rrp":{"row":0,"column":0,"band":0},"wrp":{"x":0,"y":0,"z":0}}},"spatialReference":{"valid":true,"srid":0,"refLocation":"center","affline":{"upperleftx":0.0,"upperlefty":2.0,"scalex":0.0078125,"scaley":-0.0078125,"skewx":0.0,"skewy":0.0},"gcps":{"count":0}}}