Skip to content

RS_Value

Returns the value of a single raster pixel as a double, selected by a point geometry. Returns null if the location is outside the raster or the pixel holds the band’s nodata value.

Usage

float64 RS_Value(rast: raster, point: geometry)
float64 RS_Value(rast: raster, point: geometry, band: int)

Arguments

  • rast (raster): Input raster
  • point (geometry): The pixel that contains this point is sampled (no resampling). Reprojected into the raster CRS when both carry one.
  • band (int): Band index (1-based). When omitted, defaults to band 1, but only for a single-band raster; sampling an unspecified band of a multiband raster is ambiguous and raises an error.

[!WARNING]

Experimental. This function is experimental; its behavior may change without notice.

Description

RS_Value samples one pixel of a raster. The location is given as a point geometry — the value of the pixel that contains the point is returned, with no interpolation. The band defaults to 1 when omitted, but only for a single-band raster; on a multiband raster the band must be given explicitly.

The result is NULL when the point falls outside the raster, or when the sampled pixel equals the band’s nodata value. Only 2-D rasters are supported.

Examples

SELECT RS_Value(RS_Example(), ST_Point(74.58, 110.57, 'OGC:CRS84'), 1);
┌──────────────────────────────────────────────────────────────────────────────┐
│ rs_value(rs_example(),st_point(Float64(74.58),Float64(110.57),Utf8("OGC:CRS8 │
│                                4")),Int64(1))…                               │
╞══════════════════════════════════════════════════════════════════════════════╡
│                                                                          1.0 │
└──────────────────────────────────────────────────────────────────────────────┘