r.to.vect(1grass)
π r.to.vect(1grass) β the GRASS User's Manual glow-up π
okay bestie, sit down, hydrate, because today we're converting raster maps into vector maps and it's genuinely iconic. this is r.to.vect from the GRASS User's Manual and it's about to be your new fave. π¦
πΈ NAME πΈ
r.to.vect β converts a raster map into a vector map. no cap, that's the whole gig. β¨
π KEYWORDS π
raster, conversion, geometry, vectorization
β¨ SYNOPSIS β¨
r.to.vect
r.to.vect --help
r.to.vect [-svzbct] input=name output=name type=string [column=name]
[--overwrite] [--help] [--verbose] [--quiet] [--ui]
π© Flags π©
-sβ smooths the corners of area features. soft edges, main character energy. π-vβ uses the raster values as categories instead of a unique sequence (CELL only).-zβ writes raster values as the z coordinate. heads up: no table gets created, and rn it's only supported for points.-bβ do not build vector topology. recommended when you're converting absolutely massive piles of points. πββοΈ-cβ moves centroids to more central locations inside their areas. default behavior is that centroids just vibe wherever in the area, often right up close to the boundaries.-tβ do not create an attribute table. periodt.--overwriteβ lets output files overwrite files that already exist. π--helpβ prints the usage summary.--verboseβ verbose module output, aka it tells you everything.--quietβ quiet module output, aka it tells you nothing.--uiβ forces the GUI dialog to launch.
π§ Parameters π§
input=name[required] β name of the input raster map.output=name[required] β name for the output vector map.type=string[required] β output feature type. options:point,line,area.column=nameβ name of the attribute column to store the value in. the name must be SQL compliant. default:value.
π DESCRIPTION π
r.to.vect scans that named input raster map layer, pulls points / lines / area edge features out of it, and converts all that data into GRASS vector format. it's giving glow-up transformation scene. π
π΅ Point conversion π΅
The r.to.vect program extracts data from a GRASS raster map layer and stores the output in a brand new GRASS vector file. slay.
π£ Line conversion π£
r.to.vect assumes your input map has already been thinned using r.thin. like, it assumes. do not skip that step.
r.to.vect extracts vectors (aka, "arcs") from a raster map. these arcs may represent linear features (like roads or streams), or they may represent area edge features (like political boundaries, or soil mapping units).
just so you know: r.thin and r.to.vect may create excessive nodes at every junction, and may create small spurs or "dangling lines" during the thinning and vectorization process. these excessive nodes and spurs may be removed using v.clean. so bring a broom. π§Ή
π’ Area conversion π’
r.to.vect first traces the perimeter of each unique area in the raster map layer and creates vector data to represent it. the cell category values for the raster map layer will be used to create attribute information for the resultant vector area edge data. lowkey genius.
A true vector tracing of the area edges might appear blocky, since the vectors outline the edges of raster data that are stored in rectangular cells. to produce a better-looking vector map, r.to.vect smoothes the corners of the vector data as they are being extracted. At each change in direction (i.e., each corner), the two midpoints of the corner cell (half the cell's height and width) are taken, and the line segment connecting them is used to outline this corner in the resultant vector map. (The cell's cornermost node is ignored.) Because vectors are smoothed by this program, the resulting vector map will not be "true" to the raster map from which it was created. The user should check the resolution of the geographic region (and the original data) to estimate the possible error introduced by smoothing.
bestie. fr fr. smoothing = pretty, but pretty β faithful. check your region resolution and your original data so you know how much error the smoothing snuck in. π
r.to.vect extracts only area edges from the named raster input file. If the raster map contains other data (i.e., line edges, or point data) the output may be wrong. π
By default, area centroids are often located close to boundaries and not in the middle of an area. Centroids can be more centrally located with the -c flag.
π₯ EXAMPLES π₯
The examples are based on the North Carolina sample dataset:
Conversion of raster points to vector points:
Random sampling of points:
g.region raster=elevation -p
# random sampling of points (note that r.random also writes vector points)
r.random elevation raster_output=elevrand1000 n=1000
r.to.vect input=elevrand1000 output=elevrand1000 type=point
# univariate statistics of sample points
v.univar elevrand1000 column=value type=point
# compare to univariate statistics on original full raster map
r.univar elevation
Conversion of raster lines to vector lines:
Vectorization of streams in watershed basins map:
g.region raster=elevation -p
r.watershed elev=elevation stream=elev.streams thresh=50000
r.to.vect -s input=elev.streams output=elev_streams type=line
# drop "label" column which is superfluous in this example
v.db.dropcolumn map=elev_streams column=label
v.db.renamecolumn map=elev_streams column=value,basin_id
# report length per basin ID
v.report map=elev_streams option=length units=meters sort=asc
Conversion of raster polygons to vector polygons:
Vectorization of simplified landuse class map:
g.region raster=landclass96 -p
# we smooth corners of area features
r.to.vect -s input=landclass96 output=my_landclass96 type=area
v.colors my_landclass96 color=random
β οΈ KNOWN ISSUES β οΈ
For type=line the input raster map MUST be thinned by r.thin; if not, r.to.vect may crash. it's not being dramatic, it will literally fall over. π
π SEE ALSO π
g.region, r.thin, v.clean
π«Ά AUTHORS π«Ά
Point support Bill Brown
Line support Mike Baba DBA Systems, Inc. 10560 Arrowhead Drive Fairfax, Virginia 22030
Area support Original version of r.poly: Jean Ezell and Andrew Heekin, U.S. Army Construction Engineering Research Laboratory
Modified program for smoothed lines: David Satnik, Central Washington University Updated 2001 by Andrea Aime, Modena, Italy
Update Original r.to.sites, r.line and r.poly merged and updated to 5.7 by Radim Blazek
β SOURCE CODE β
Available at: r.to.vect source code (history)
Latest change: Friday Apr 17 01:04:26 2026 in commit: 32a143358df26b2e518b03c7e0d79541e8d1e5b1
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
and that's the whole page, bestie!! πβ¨ the fine print says Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual β and yes, the manual page version tag on the bottom is also GRASS 8.5.0, r.to.vect(1grass). now go vectorize something gorgeous. ππ¦π
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· 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