v.what.rast(1grass)

πŸ’– NAME πŸ’–

v.what.rast β€” the manual page, the moment, the icon. 🫢 She uploads raster values at positions of vector points to the table. That's it, that's the whole job, and she does it flawlessly, no cap.


🏷️ 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]   [separator=character]
format=name  [--help]  [--verbose]  [--quiet]  [--ui]

🚩 Flags

  • -i β€” Interpolate values from the nearest four cells πŸ‘€βœ¨
  • -p β€” Print categories and values instead of updating the database πŸ–¨οΈ (she talks, she doesn't write)
  • --help β€” Print usage summary
  • --verbose β€” Verbose module output
  • --quiet β€” Quiet module output
  • --ui β€” Force launching GUI dialog πŸͺŸ

πŸŽ€ Parameters

  • map=name [required] β€” Name of vector points map for which to edit attributes. Also can be a data source for direct OGR access.
  • layer=string β€” Layer number or name. Real talk: 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 πŸ”
  • 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
  • separator=character β€” Field separator for CSV style output. Special characters: pipe, comma, space, tab, newline. Default: comma
  • format=name [required] β€” Output format. Options: plain, csv, json. Default: plain
    • plain: Human readable text output
    • csv: CSV (Comma Separated Values)
    • json: JSON (JavaScript Object Notation)

🌸 DESCRIPTION 🌸

So v.what.rast retrieves a raster value from a given raster map for each point or centroid stored in a given vector map. Then she can either update a column in the linked vector attribute table with the retrieved raster cell value, or just print it. Main character energy either way. πŸ‘‘

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. She's proactive like that. πŸŽ€

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. Fr fr, that's the whole point.

If the -p flag is used, then the attribute table is not updated and the results are printed to standard output.


πŸ¦‹ 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.

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. Both paths lead to NULL, bestie, it's giving void. πŸ’€

v.what.rast operates on the attribute table. If you wanna modify the vector geometry instead, use v.drape.

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'|'). In the case of a NULL result, a "*" will be printed in lieu of the value.

⚠️ The interpolation flag is only useful for continuous value raster maps. If a categorical raster is given as input, the results will be nonsense. 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.

🌈 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)

Latest change: Thursday Oct 02 14:39:13 2025 in commit: 1850489bf42c72d8dcfe2e4db1738441b4a7dc43

Main index | Vector index | Topics index | Keywords index | Graphical index | Full index


And that's the whole page, bestie β€” stay slay, query responsibly, and remember: all of this lives in the v.what.rast manual from GRASS 8.5.0, Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual. Periodt. πŸ’œβœ¨

πŸ“¦ where this page comes from