v.sample(1grass)

✨ v.sample β€” the manual page, but make it cute ✨

okay bestie, welcome to v.sample(1grass) πŸ’– this is the GRASS User's Manual page for it, and no I will not be normal about it.

🌸 NAME 🌸

v.sample β€” it samples a raster map at vector point locations. that's it, that's the whole job, and it does it beautifully. πŸŽ€

πŸ”‘ KEYWORDS πŸ”‘

vector, sampling, raster β€” iykyk πŸ¦‹

🌈 SYNOPSIS 🌈

v.sample
v.sample --help
v.sample input=name  [layer=string]  column=name output=name raster=name
[method=string]   [zscale=float]   [--overwrite]  [--help]  [--verbose]
[--quiet]  [--ui]

look at that. mostly required args, a couple optional ones, and the classic GRASS flags doing their thing. periodt πŸ’…

🫢 Flags

  • --overwrite β€” lets your output files just bulldoze whatever was already there. existing files? gone. allow output files to overwrite existing files.
  • --help β€” prints the usage summary. your safety net when you forget what anything means. 😭
  • --verbose β€” verbose module output. it will tell you EVERYTHING, and honestly? good for it.
  • --quiet β€” quiet module output. the opposite vibe. shhh. 🀫
  • --ui β€” force launches the GUI dialog. buttons!! ✨

🧚 Parameters

  • input=name [required] β€” name of the input vector point map. or, plot twist, it can be a data source for direct OGR access. main character energy either way. πŸ‘‘
  • layer=string β€” layer number or name. here's the tea: vector features can have category values in different layers, and this number determines which layer to use. when you're doing direct OGR access, this is instead the layer name. Default: 1
  • column=name [required] β€” name of the attribute column to use for comparison.
  • output=name [required] β€” name for the output vector map where the differences get stored. the receipts, basically. πŸ“
  • raster=name [required] β€” name of the raster map to be sampled. the star of the show.
  • method=string β€” sampling interpolation method. the options are: nearest, bilinear, bicubic. Default: nearest
    • nearest β€” nearest-neighbor interpolation
    • bilinear β€” bilinear interpolation
    • bicubic β€” bicubic interpolation
  • zscale=float β€” scaling factor for values read from the raster map. the sampled values get multiplied by this factor. Default: 1.0

πŸ’œ DESCRIPTION πŸ’œ

so v.sample samples a GRASS raster map at the point locations in your input file. and it does it via one of three routes: cubic convolution interpolation, bilinear interpolation, or nearest neighbor sampling (that last one is the default, if you were wondering πŸ’…).

this program can be especially useful when you're sampling for cross validation of interpolations whose output happens to be a raster map. it's giving "the tool you didn't know you needed". 🌟

πŸ“ NOTES πŸ“

okay here's the important stuff, bestie, don't scroll past:

  • the output points will have the easting and northing of the input points. literally the same coords, no cap.
  • the input category value is used.
  • the input attribute, the raster value, and the difference all get written to output. three-for-one deal. πŸ”₯
  • when NULL values are encountered for a cell, a zero value is used instead. in those cases, you might get more acurrate results by using the default nearest neighbor comparisons. (that's spelled the original way, live with it 😌)
  • this program may not work properly with lat-long data when the -bc flags are used.
  • when interpolation is done (i.e., when the -bc flags are used), values are assumed to be located at the centroid of grid cells. so your current resolution settings matter a LOT. don't ignore them. ⭐
lowkey a warning: lat-long data + -bc flags = possible chaos. and resolution settings when interpolating? not optional to care about. πŸ™ˆ

πŸŽ€ EXAMPLE πŸŽ€

this is a comparison of "elev_ned_30m" and "elev_srtm_30m" North Carolina sample dataset elevation models at random positions. iconic dataset behaviour, honestly. πŸ¦‹

# set computational region:
g.region raster=elev_srtm_30m -p
# generate random points:
v.random output=random n=100
# add table with one column:
v.db.addtable random col="elev_srtm30 double precision"
# transfer elevations at random points into table:
v.what.rast map=random rast=elev_srtm_30m col=elev_srtm30
# verify:
v.db.select random
# perform sampling on other elevation map:
v.sample in=random col=elev_srtm30 rast=elev_ned_30m out=elev_samples
#verify:
v.db.select elev_samples
#univariate statistics of differences between elevation maps:
v.univar elev_samples column=diff type=point

see how it flows?? set region, make points, build a table, transfer values, verify, sample, verify again, then univar the diffs. a whole little journey and it ATE. πŸ’…βœ¨

πŸ‘€ SEE ALSO πŸ‘€

  • g.region
  • v.random
  • v.what.rast
  • Image Sampling Methods - GRASS Tutorial on s.sample (available as s.sample-tutorial.ps.gz)

πŸ’– AUTHORS πŸ’–

  • James Darrell McCauley β€” when he was at: Agricultural Engineering Purdue University
  • Updated for GRASS 5.0 by Eric G. Miller
  • Updated for GRASS 5.7 by Radim Blazek

🌈 SOURCE CODE 🌈

available at: v.sample source code (history)

latest change: Friday May 09 14:33:40 2025 in commit: b356c7e108fcbeca77474c8e83ebec8f1e7b3e4a

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


and that's the whole page bestie 🫢 this came out of GRASS 8.5.0 β€” the GRASS 8.5.0 Reference Manual β€” with Β© 2003-2026 GRASS Development Team holding it down. this specific page was last touched Friday May 09 14:33:40 2025 in commit b356c7e108fcbeca77474c8e83ebec8f1e7b3e4a, and it's filed under v.sample(1grass). go sample something. πŸ˜­πŸ’œ

πŸ“¦ where this page comes from