geo-registry

Extract Values to Points

Adds to each point the value of the raster at its location.

Pitfall. Points and raster in different CRSs give wrong or empty values unless the engine reprojects the points first.
Pitfall. Some engines interpolate by default, so values differ from the cell's value except at cell centres.
Pitfall. Points outside the raster or on nodata cells get nodata, null or an error depending on the engine.
About this operation
Also called sample raster values, raster sampling, point query, Extract Multi Values to Points, drill a raster
Group raster/extraction
Checks crs.agreement, raster.nodata
Pitfalls 3 listed above
Columbus tool Not stated
Notes Not stated
Status active
Broader Not stated
Narrower Not stated
Related

Parameters

Name Type Required Default Values Note
resampling enum no nearest nearest, bilinear nearest: the value of the cell the point falls in; bilinear: interpolated from the four nearest cell centres.

Inputs and outputs

Direction Name Type Geometry Note
Input points vector point Not stated
Input raster raster Not stated Not stated
Output output vector point Not stated

In each engine

Engine Tool Parameters Differences
gdal gdal raster pixel-info
  • resampling → resampling
  • raster → input
  • points → position-dataset
  • output → output
  • Takes positions as coordinates (position) or from a vector dataset (position-dataset); writes the points with the values as fields.
grass v.what.rast
  • resampling → flag_i : nearest = no; bilinear = yes
  • raster → raster
  • points → map
  • Updates a column of the point map's attribute table, which must exist first (v.db.addcolumn); flag p prints the values instead.
postgis-raster st_value
  • resampling → resample
  • raster → rast
  • points → pt
  • Returns the value at one point; run it once per point row. resample also offers cubic and cubic spline interpolation.
Preset: {"band":1}
qgis native:rastersampling
  • resampling always nearest
  • raster → RASTERCOPY
  • points → INPUT
  • output → OUTPUT
  • Adds one field per band, named COLUMN_PREFIX plus the band number (SAMPLE_1).
rasterio rasterio.sample.sample_gen
  • resampling always nearest
  • raster → dataset
  • points → xy : An iterable of (x, y) coordinate pairs in the raster's CRS.
  • Yields an array of band values per point; DatasetReader.sample is the same as a method of an open raster.
rasterstats rasterstats.gen_point_query
  • resampling → interpolate
  • raster → raster
  • points → vectors
  • Interpolates (bilinear) by default; returns one value per point (a generator; point_query returns a list).
terra terra::extract
  • resampling → method : nearest = simple; bilinear = bilinear
  • raster → x
  • points → y
  • Returns a data frame of ID and one column per layer, not the points; bind = TRUE returns the points with the values.
whiteboxtools ExtractRasterValuesAtPoints
  • resampling always nearest
  • raster → inputs
  • points → points
  • Writes VALUE1, VALUE2, ... (one per raster) into the points file itself; out_text also prints them.