GRASS logo

Note: This document is for an older version of GRASS GIS that will be discontinued soon. You should upgrade, and read the current manual page.

NAME - Converts a raster map into a vector map.


raster, conversion, geometry, vectorization

SYNOPSIS --help [-svzbt] input=name output=name type=string [column=name] [--overwrite] [--help] [--verbose] [--quiet] [--ui]


Smooth corners of area features
Use raster values as categories instead of unique sequence (CELL only)
Write raster values as z coordinate
Table is not created. Currently supported only for points.
Do not build vector topology
Recommended for massive point conversion
Do not create attribute table
Allow output files to overwrite existing files
Print usage summary
Verbose module output
Quiet module output
Force launching GUI dialog


input=name [required]
Name of input raster map
output=name [required]
Name for output vector map
type=string [required]
Output feature type
Options: point, line, area
Name of attribute column to store value
Name must be SQL compliant
Default: value

Table of contents

DESCRIPTION scans the named input raster map layer, extracts points, lines or area edge features from it, converts data to GRASS vector format.

Point conversion

The program extracts data from a GRASS raster map layer and stores output in a new GRASS vector file.

Line conversion assumes that the input map has been thinned using r.thin. extracts vectors (aka, "arcs") from a raster map. These arcs may represent linear features (like roads or streams), or may represent area edge features (like political boundaries, or soil mapping units).

r.thin and 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.

Area conversion 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.

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, 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. 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.


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 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 -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 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 -s input=landclass96 output=my_landclass96 type=area
v.colors my_landclass96 color=random


For type=line the input raster map MUST be thinned by r.thin; if not, may crash.


g.region, r.thin, v.clean


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

Original, r.line and r.poly merged and updated to 5.7 by Radim Blazek


Available at: source code (history)

Latest change: Monday Nov 18 20:15:32 2019 in commit: 1a1d107e4f6e1b846f9841c2c6fabf015c5f720d

Note: This document is for an older version of GRASS GIS that will be discontinued soon. You should upgrade, and read the current manual page.

Main index | Raster index | Topics index | Keywords index | Graphical index | Full index

© 2003-2023 GRASS Development Team, GRASS GIS 7.8.9dev Reference Manual