v.to.rast(1)
π v.to.rast β the glow-up from vector to raster β¨
okay bestie, so this is v.to.rast, a GRASS GIS User's Manual page, and it's literally the tool that turns your vector map into a raster map. rasterize era, no cap. π
KEYWORDS: vector, conversion, raster, rasterization
β¨ SYNOPSIS β¨
v.to.rast
v.to.rast --help
v.to.rast [-d] input=name [layer=string] [type=string[,string,...]]
[type=string[,string,...]]
[cats=range] [where=sql_query] output=name use=string
[attribute_column=name] [rgb_column=name] [label_column=name]
[value=float] [memory=memory in MB] [--overwrite] [--help]
[--verbose] [--quiet] [--ui]
π© Flags
-dβ Create densified lines (default: thin lines). All cells touched by the line will be set, not only those on the render path. it's giving "full coverage, no crumbs left behind" π--overwriteβ Allow output files to overwrite existing files. respectfully, she will bulldoze what's there. π--helpβ Print usage summary.--verboseβ Verbose module output. she will tell you EVERYTHING. π£οΈ--quietβ Quiet module output. she will tell you nothing. shhh. π€«--uiβ Force launching GUI dialog.
π Parameters
input=name[required] β Name of input vector map. Or data source for direct OGR access.layer=stringβ Layer number or name. 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:1type=string[,string,...]β Input feature type. Options:point,line,boundary,centroid,area. Default:point,line,areacats=rangeβ Category values. Example:1,3,7-9,13where=sql_queryβ WHERE conditions of SQL statement without 'where' keyword. Example:income < 1000 and population >= 10000output=name[required] β Name for output raster map. this is your baby, name her well π¦use=string[required] β Source of raster values. Options:attr,cat,value,z,dirattr: read values from attribute tablecat: use category valuesvalue: use value specified byvalueoptionz: use z coordinate (points or contours only)dir: line direction in degrees CCW from east (lines only)
attribute_column=nameβ Name of column for 'attr' parameter (data type must be numeric)rgb_column=nameβ Name of color definition column (withRRR:GGG:BBBentries)label_column=nameβ Name of column used as raster category labelsvalue=floatβ Raster value (foruse=value). Default:1memory=memory in MBβ Maximum memory to be used (in MB). Cache size for raster rows. Default:300
π DESCRIPTION π
v.to.rast transforms GRASS vector map layers into GRASS raster map layer format. and optionally?? attributes can be converted to raster category labels. so you get your labels AND your raster. we love a multitasker. β¨
πΈ NOTES πΈ
okay so listen up because this part is the "please don't mess this up" section.
In order to avoid unexpected results, the type of vector features should always be specified. The default is to convert all vector features, but if only e.g. areas should be converted use type=area rather than type=point,line,area. like, be specific bestie. π«Ά
v.to.rast will only affect data in areas lying inside the boundaries of the current geographic region. A grid cell belongs to the area where the grid cell center falls into.
Before running v.to.rast, the user should therefore ensure that the current geographic region is correctly set and that the region resolution is at the desired level. check your region first, i'm begging π
Either the column parameter or the value parameter must be specified. The use option may be specified alone when using the dir option.
use options are:
attr- read values from attribute table (default)cat- read values from categoryvalue- use value specified byvalueoptionz- use z coordinate (points or contours only)dir- line direction in degrees counterclockwise from east (lines only)
The column parameter uses an existing column from the vector map database table as the category value in the output raster map. Existing table columns can be shown by using db.describe.
An empty raster map layer will be created if the vector map layer has not been assigned category/attribute labels (e.g., through use of v.category option=add). yeah. empty. nothing. a void. π
Otherwise:
- Labeled areas and/or centroids will produce filled raster coverages with edges that straddle the original area boundary as long as the boundary is NOT labeled. (Use
v.category option=del type=boundaryto remove.) - Labeled lines and boundaries will produce lines of raster cells which touch the original vector line. This tends to be more aggressive than area-only conversions.
- Points and orphaned centroids will be converted into single cells on the resultant raster map.
Line directions are given in degrees counterclockwise from east.
Raster category labels are supported for all of use= except use=z. π«
The -d flag applies only to lines and boundaries, the default is to set only those cells on the render path (thin line).
Boundaries (usually without categories) can be rasterized with:
v.to.rast type=boundary layer=-1 use=value
π EXAMPLES π
π Convert a vector map and use column SPEED from attribute table
db.describe -c table=vect_map
ncols:3
Column 1: CAT
Column 2: SPEED
Column 3: WIDTH
v.to.rast input=vect_map output=raster_map attribute_column=SPEED type=line
π Calculate stream directions from a river vector map (Spearfish)
v.to.rast input=streams output=streamsdir use=dir
π Calculate slope along path
Using slope and aspect maps, compute slope along a bus route (use full NC sample dataset):
g.region raster=elevation -p
r.slope.aspect elevation=elevation slope=slope aspect=aspect
# compute direction of the bus route
v.to.rast input=busroute11 type=line output=busroute11_dir use=dir
# extract steepest slope values and transform them into slope along path
r.mapcalc "route_slope = if(busroute11, slope)"
r.mapcalc "route_slope_dir = abs(atan(tan(slope) * cos(aspect - busroute11_dir)))"
Slope in degrees along bus route. π
π Convert a vector polygon map to raster including descriptive labels
In this example, the ZIP code vector map is rasterized (North Carolina sample dataset):
# rasterize ZIP codes at 50m raster resolution
g.region vector=zipcodes_wake res=50 -ap
# vector to raster conversion, with category labels
v.to.rast input=zipcodes_wake output=myzipcodes use=attr attribute_column="ZIPNUM" label_column="NAME"
π Convert vector points to raster with raster cell binning
In this example, the number of schools per raster cell are counted (North Carolina sample dataset):
g.copy vector=schools_wake,myschools_wake
# set computation region for raster binning
g.region vector=myschools_wake res=5000 -p -a
# add new column for counting
v.db.addcolumn myschools_wake column="value integer"
v.db.update myschools_wake column=value value=1
# verify attributes
v.db.select myschools_wake column=cat,value
v.out.ascii input=myschools_wake output=- column=value
# export and import on the fly, use 4th column (value) as input
v.out.ascii input=myschools_wake output=- column=value | r.in.xyz input=- \
z=4 output=schools_wake_aggreg method=sum
d.mon wx0
d.rast schools_wake_aggreg
d.vect schools_wake
d.grid 5000
Number of schools per raster cell. π«β¨
π¦ SEE ALSO π¦
db.describe, v.category
π AUTHORS π
- Original code: Michael Shapiro, U.S. Army Construction Engineering Research Laboratory
- GRASS 6.0 updates: Radim Blazek, ITC-irst, Trento, Italy
- Stream directions: Jaro Hofierka and Helena Mitasova
- GRASS 6.3 code cleanup and label support: Brad Douglas
π SOURCE CODE π
Available at: v.to.rast source code (history)
Accessed: Saturday Jan 17 05:41:32 2026
Main index | Vector index | Topics index | Keywords index | Graphical index | Full index
Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual
okay that's the whole thing bestie, you're officially a rasterizing icon now π this was GRASS 8.4.2, v.to.rast(1), and she ate. periodt. πβ¨π¦
π¦ 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