v.what.vect(1grass)

✨ v.what.vect ✨

okay so bestie, this is v.what.vect from the GRASS User's Manual and it's literally the "copy the vibe from that map's table over to this map's table" tool πŸ’…

🌸 NAME 🌸

v.what.vect β€” uploads vector values at positions of vector points to the table. no cap, that's the whole job 🫢

πŸŽ€ KEYWORDS πŸŽ€

vector, sampling, database, position, querying, attribute table


πŸ’– SYNOPSIS πŸ’–

v.what.vect
v.what.vect --help
v.what.vect map=name  [layer=string]  column=name query_map=name
[query_layer=string]  query_column=name  [dmax=float]   [--help]
[--verbose]  [--quiet]  [--ui]

πŸ¦‹ Flags:

  • --help β€” prints the usage summary, obvi
  • --verbose β€” verbose module output (she's chatty, we love her)
  • --quiet β€” quiet module output (she's giving mystery)
  • --ui β€” forces the GUI dialog to launch

🌈 Parameters:

  • map=name [required] β€” name of the vector points map whose attributes you wanna edit. can also be a data source for direct OGR access.
  • layer=string β€” layer number or name. vector features can carry category values in different layers, so this number tells her which layer to use. when you're doing direct OGR access this is the layer name. default: 1
  • column=name [required] β€” name of the attribute column that gets updated with the query result
  • query_map=name [required] β€” name of the vector map to be queried. or a data source for direct OGR access.
  • query_layer=string β€” layer number or name, same situation as layer: different layers, different category values, this picks which one. with direct OGR access it's the layer name. default: 1
  • query_column=name [required] β€” name of the attribute column to be queried
  • dmax=float β€” maximum query distance in map units (meters for ll). default: 0.0

πŸ‘‘ DESCRIPTION πŸ‘‘

so v.what.vect transfers attributes out of the query_map's attribute table and into the map's attribute table. icon behavior, truly.

you can use it both ways:

  • from a polygon map's table ➑️ into a point vector map's attribute table
  • or the other way around, from a point map ➑️ into the attribute table of a polygon map (peep the examples)

The script is based on v.distance. periodt.

πŸ’€ NOTES πŸ’€

  • the upload column you're stuffing query results into must already exist in map. if it doesn't, use v.db.addcolumn to add one. don't come crying, just add the column bestie πŸ₯²
  • use the dmax parameter to control the query distance tolerance, i.e. how far map's points/centroids can be from the query_map features. for further options, use v.distance.
  • here's a lil gotcha: if you have a multipoint input map with several points sharing the same category number, the query result can come out as NULL if that same category number falls into different query_map polygons. not me getting a NULL out of nowhere 😭
  • when you're transferring attributes from a point map into a polygon map, dmax has to be larger than zero β€” it'll be determined by the distance between query points and polygon centroids. and importantly: distance is in meters for latitude-longitude projects. remember that fr fr.
  • if one or both of the input vector maps are 3D, features need to touch in the 3rd dimension (z coordinate) too before attributes get transferred. no z-touch, no transfer. 🧚

πŸ”₯ EXAMPLES πŸ”₯

Example one: hospital glow-up πŸ₯

in this one, the hospitals point map from the North Carolina dataset gets copied into the current mapset, a new attribute column gets added, and the urban names from the urbanarea polygon map get transferred onto the hospital point locations in the myhospitals map:

g.copy vect=hospitals,myhospitals
v.db.addcolumn myhospitals column="urb_name varchar(25)"
v.what.vect myhospitals query_map=urbanarea column=urb_name query_column=NAME
# verification:
v.db.select myhospitals

Example two: EU CORINE + geonames crossover event ⭐

here, city names, population data and other goodies from Geonames.org country files get transferred onto selected EU CORINE landuse/landcover classes ("Continuous urban fabric", 111, and "Discontinuous urban fabric", 112). Note: The example is in UTM projection to which the input maps have been projected beforehand.

# extract populated places from geonames
v.extract geonames_IT where="featurecla='P'" output=geonames_IT_cities
# add new column
v.db.addcol corine_code111_112_cities column="gnameid double precision"
# transfer geonameid (3000m maximal distance between points and centroids)
v.what.vect corine_code111_112_cities query_map=geonames_IT_cities column=gnameid \
            query_column=geonameid dmax=3000
# now gnameid can be used for v.db.join to join further
# attributes from geonames.org

πŸ’œ SEE ALSO πŸ’œ

v.db.addcolumn, v.db.select, v.distance, v.rast.stats, v.what.rast, v.what.rast3, v.vect.stats

🌟 AUTHOR 🌟

Markus Neteler

πŸŽ€ SOURCE CODE πŸŽ€

Available at: v.what.vect source code (history)

Latest change: Friday Feb 07 19:16:09 2025 in commit: a82a39f673b97fafcfce1604dc3e6015cb96487a

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


okay and for the cute sign-off Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual 🫢 and yeah this page ships with GRASS 8.5.0, so respect the version, iykyk πŸ’– go transfer those attributes bestie, you're gonna ate ✨

πŸ“¦ where this page comes from