v.what.rast(1)
π NAME π
okay bestie, listen up β v.what.rast uploads raster values at positions of vector points straight into the table. that's it. that's the whole thing. and it ate. π
πΈ KEYWORDS πΈ
vector, sampling, raster, position, querying, attribute table, surface information
β¨ SYNOPSIS β¨
v.what.rast
v.what.rast --help
v.what.rast [-ip] map=name [layer=string] [type=string[,string,...]]
raster=name [column=name] [where=sql_query] [--help] [--verbose]
[--quiet] [--ui]
π Flags π
-iβ interpolate values from the nearest four cells. like, it reads the room around the point instead of just grabbing one cell.-pβ print categories and values instead of updating the database. no cap, it just shows you the tea.--helpβ print usage summary.--verboseβ verbose module output (the module is a yapper).--quietβ quiet module output (the module is β¨mysteriousβ¨).--uiβ force launching GUI dialog.
π¦ Parameters π¦
map=name[required] β name of vector points map for which to edit attributes. orrr it can be a data source for direct OGR access. versatile queen.layer=stringβ layer number or name. here's the thing: vector features can have category values in different layers, and this number determines which layer to use. when used with direct OGR access this is the layer name. default:1.type=string[,string,...]β input feature type. options:point,centroid. default:point.raster=name[required] β name of existing raster map to be queried. bestie it has to already exist, we're not manifesting here.column=nameβ name of attribute column to be updated with the query result.where=sql_queryβ WHERE conditions of SQL statement without'where'keyword. example:income < 1000 and population >= 10000.
π DESCRIPTION π
v.what.rast retrieves raster value from a given raster map for each point or centroid stored in a given vector map. it can update a column in the linked vector attribute table with the retrieved raster cell value, or print it. dealer's choice π
the column type needs to be numeric (integer, float, double, ...). and if the column doesn't exist in the vector attribute table, then the module will create the new column of type corresponding with the input raster map. it literally just makes it for you. main character energy.
if the -p flag is used, then the attribute table is not updated and the results are printed to standard output. she's just showing off, not committing.
if the -i flag is used, then the value to be uploaded to the database is interpolated from the four nearest raster cells values using an inverse distance weighting method (IDW). this is useful for cases when the vector point density is much higher than the raster cell size. iykyk. π«Ά
π NOTES π
points and centroid with shared category number cannot be processed. to solved this, unique categories may be added with v.category in a separate layer. (yes, the original says "to solved this" and honestly? relatable. keeping it.)
if multiple points have the same category, the attribute value is set to NULL. if the raster value is NULL, then attribute value is set to NULL. so much NULL bestie, it's giving void.
v.what.rast operates on the attribute table. to modify the vector geometry instead, use v.drape. different girl, different job.
categories and values are output unsorted with the print flag. to sort them, pipe the output of this module into the UNIX sort tool (sort -n). if you need coordinates, after sorting use v.out.ascii and the UNIX paste tool (paste -d'|'). and in the case of a NULL result, a "*" will be printed in lieu of the value. cute little asterisk, doing its best β
the interpolation flag is only useful for continuous value raster maps. if a categorical raster is given as input, the results will be nonsense. like, genuinely meaningless. don't do it. π since the search window is limited to four raster cells there may still be raster cell-edge artifacts visible in the results β this compromise has been made for processing speed. if one or more of the nearest four raster cells is NULL, then only the raster cells containing values will be used in the weighted average. she adapts. π
π EXAMPLES π
πΈ Transferring raster values into existing attribute table of vector points map πΈ
reading values from raster map at position of vector points, writing these values into a column of the attribute table connected to the vector map:
# work on copy of original geodetic points map
g.copy vector=geodetic_pts,mygeodetic_pts
# set computational region to raster map to be queried
g.region raster=elev_state_500m -p
# query raster cells (a new column will be added to existing table)
v.what.rast map=mygeodetic_pts raster=elev_state_500m column=height
# compare official geodetic heights to those of elevation model
v.db.select map=mygeodetic_pts columns=Z_VALUE,height separator=comma
π¦ Transferring raster values into new vector points map π¦
in case of a vector map without attached attribute table, first add a new attribute table. this table is then populated with values queried from the raster map:
# create new random vector points map
v.random pnts n=100
# add new table, link to map
v.db.addtable map=pnts column="height double precision"
# set computational region to raster map to be queried
g.region raster=elevation -p
# query raster map and upload values to vector table into specified column
v.what.rast map=pnts raster=elevation column=height
# verify new attribute table:
v.db.select pnts
# verify statistics of uploaded values:
v.univar map=pnts column=height type=point
π SEE ALSO π
v.category, v.db.addtable, v.db.select, v.drape, v.univar, v.rast.stats, v.what.vect
π AUTHORS π
Radim Blazek Hamish Bowman (interpolation)
β SOURCE CODE β
available at: v.what.rast source code (history)
accessed: Saturday Jan 17 05:41:33 2026
Main index | Vector index | Topics index | Keywords index | Graphical index | Full index
and that's the whole page bestie π«Ά this one lives in the GRASS GIS 8.4.2 Reference Manual, Β© 2003-2025 GRASS Development Team β and yeah, the header and footer both say GRASS 8.4.2, she's consistent. now go query some rasters, you absolute legend. β¨π π
π¦ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms