ST_InterpolateRaster — Interpolates a gridded surface based on an input set of 3-d points, using the X- and Y-values to position the points on the grid and the Z-value of the points as the surface elevation.
raster ST_InterpolateRaster(geometry input_points, text algorithm_options, raster template, integer template_band_num=1
Interpolates a gridded surface based on an input set of 3-d points, using the X- and Y-values to position the points on the grid and the Z-value of the points as the surface elevation. There are five interpolation algorithms available: inverse distance, inverse distance nearest-neighbor, moving average, nearest neighbor, and linear interpolation. See the gdal_grid documentation for more details on the algorithms and their parameters. For more information on how interpolations are calculated, see the GDAL grid tutorial.
Input parameters are:
The points to drive the interpolation. Any geometry with Z-values is acceptable, all points in the input will be used.
A string defining the algorithm and algorithm options, in the format used by gdal_grid. For example, for an inverse-distance interpolation with a smoothing of 2, you would use "invdist:smoothing=2.0"
A raster template to drive the geometry of the output raster. The width, height, pixel size, spatial extent and pixel type will be read from this template.
By default the first band in the template raster is used to drive the output raster, but that can be adjusted with this parameter.
SELECT ST_InterpolateRaster( 'MULTIPOINT(10.5 9.5 1000, 11.5 8.5 1000, 10.5 8.5 500, 11.5 9.5 500)'::geometry, 'invdist:smoothing:2.0', ST_AddBand(ST_MakeEmptyRaster(200, 400, 10, 10, 0.01, -0.005, 0, 0), '16BSI') )