All Products
Search
Document Center

ApsaraDB RDS:ST_InterpolateRaster

Last Updated:Sep 19, 2023

This topic describes the ST_InterpolateRaster function. This function interpolates a raster object based on the set of 3D points and interpolation conditions and returns the interpolation result as a new raster object. A 3D point is expressed in the (x,y,z) format.

Syntax

raster ST_InterpolateRaster(
    geometry input_points,
    integer width,
    integer height,
    cstring interpolateOptions,
    cstring storageOptions);

Parameters

Parameter

Description

input_points

The set of interpolation points.

width

The number of columns of the raster data.

height

The number of rows of the raster data.

interpolateOptions

The JSON string that describes the information about the spatial interpolation algorithm.

storageOption

The JSON string that describes the chunks for storing the raster object.

The following table describes the fields of the interpolateOptions parameter.

Field

Description

Type

Default value

Configuration

method

The interpolation method.

string

IDW

Only IDW interpolation is supported.

radius

The search radius.

double

0.0

If the value of this field is 0, the search radius is calculated based on the number of input points and the area.

power

The interpolation weight.

double

2.0

None.

max_points

The maximum number of points.

integer

10

The maximum number of points must be greater than the value of the min_points field.

min_points

The minimum number of points.

integer

2

None.

nodata

The empty value.

double

0.0

None.

parallel

The degree of parallelism (DOP).

integer

1

None.

The following table describes the fields of the storageOption parameter.

Field

Description

Type

Format

Default value

Description

chunkdim

The size of each chunk.

string

(w, h, b)

Same as the size of each chunk in the original object

None.

chunktable

The name of the chunk table that you want to specify.

string

None.

None.

If this field is not specified, a temporary table is created.

celltype

The pixel type of the raster object.

string

None.

16BUI

The pixel type of a raster object.

Valid values:

  • 8BSI

  • 8BUI

  • 16BSI

  • 16BUI

  • 32BSI

  • 32BUI

  • 32BF

  • 64BF

Examples

-- The following code provides 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}}}

-- The following code provides an example in which the parallel parameter is specified.
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}}}