1v.to.rast(1) GRASS GIS User's Manual v.to.rast(1)
2
3
4
6 v.to.rast - Converts (rasterize) a vector map into a raster map.
7
9 vector, conversion, raster, rasterization
10
12 v.to.rast
13 v.to.rast --help
14 v.to.rast [-d] input=name [layer=string] [type=string[,string,...]]
15 [cats=range] [where=sql_query] output=name use=string
16 [attribute_column=name] [rgb_column=name] [label_column=name]
17 [value=float] [memory=memory in MB] [--overwrite] [--help]
18 [--verbose] [--quiet] [--ui]
19
20 Flags:
21 -d
22 Create densified lines (default: thin lines)
23 All cells touched by the line will be set, not only those on the
24 render path
25
26 --overwrite
27 Allow output files to overwrite existing files
28
29 --help
30 Print usage summary
31
32 --verbose
33 Verbose module output
34
35 --quiet
36 Quiet module output
37
38 --ui
39 Force launching GUI dialog
40
41 Parameters:
42 input=name [required]
43 Name of input vector map
44 Or data source for direct OGR access
45
46 layer=string
47 Layer number or name
48 Vector features can have category values in different layers. This
49 number determines which layer to use. When used with direct OGR
50 access this is the layer name.
51 Default: 1
52
53 type=string[,string,...]
54 Input feature type
55 Options: point, line, boundary, centroid, area
56 Default: point,line,area
57
58 cats=range
59 Category values
60 Example: 1,3,7-9,13
61
62 where=sql_query
63 WHERE conditions of SQL statement without ’where’ keyword
64 Example: income < 1000 and population >= 10000
65
66 output=name [required]
67 Name for output raster map
68
69 use=string [required]
70 Source of raster values
71 Options: attr, cat, val, z, dir
72 attr: read values from attribute table
73 cat: use category values
74 val: use value specified by value option
75 z: use z coordinate (points or contours only)
76 dir: line direction in degrees CCW from east (lines only)
77
78 attribute_column=name
79 Name of column for ’attr’ parameter (data type must be numeric)
80
81 rgb_column=name
82 Name of color definition column (with RRR:GGG:BBB entries)
83
84 label_column=name
85 Name of column used as raster category labels
86
87 value=float
88 Raster value (for use=val)
89 Default: 1
90
91 memory=memory in MB
92 Maximum memory to be used (in MB)
93 Cache size for raster rows
94 Default: 300
95
97 v.to.rast transforms GRASS vector map layers into GRASS raster map
98 layer format. Optionally, attributes can be converted to raster cate‐
99 gory labels.
100
102 In order to avoid unexpected results, the type of vector features
103 should always be specified. The default is to convert all vector fea‐
104 tures, but if only e.g. areas should be converted use type=area rather
105 than type=point,line,area.
106
107 v.to.rast will only affect data in areas lying inside the boundaries of
108 the current geographic region. A grid cell belongs to the area where
109 the grid cell center falls into.
110
111 Before running v.to.rast, the user should therefore ensure that the
112 current geographic region is correctly set and that the region resolu‐
113 tion is at the desired level.
114
115 Either the column parameter or the value parameter must be specified.
116 The use option may be specified alone when using the dir option.
117
118 use options are:
119
120 · attr - read values from attribute table (default)
121
122 · cat - read values from category
123
124 · val - use value specified by value option
125
126 · z - use z coordinate (points or contours only)
127
128 · dir - line direction in degrees counterclockwise from east
129 (lines only)
130
131 The column parameter uses an existing column from the vector map data‐
132 base table as the category value in the output raster map. Existing ta‐
133 ble columns can be shown by using db.describe.
134
135 An empty raster map layer will be created if the vector map layer has
136 not been assigned category/attribute labels (e.g., through use of
137 v.category option=add).
138
139 Otherwise:
140
141 · Labeled areas and/or centroids will produce filled raster cov‐
142 erages with edges that straddle the original area boundary as
143 long as the boundary is NOT labeled.
144 (Use v.category option=del type=boundary to remove.)
145
146 · Labeled lines and boundaries will produce lines of raster cells
147 which touch the original vector line. This tends to be more
148 aggressive than area-only conversions.
149
150 · Points and orphaned centroids will be converted into single
151 cells on the resultant raster map.
152
153 Line directions are given in degrees counterclockwise from east.
154
155 Raster category labels are supported for all of use= except use=z.
156
157 The -d flag applies only to lines and boundaries, the default is to set
158 only those cells on the render path (thin line).
159
160 Boundaries (usually without categories) can be rasterized with
161 v.to.rast type=boundary layer=-1 use=val
162
164 Convert a vector map and use column SPEED from attribute table
165 db.describe -c table=vect_map
166 ncols:3
167 Column 1: CAT
168 Column 2: SPEED
169 Column 3: WIDTH
170 v.to.rast input=vect_map output=raster_map attribute_column=SPEED type=line
171
172 Calculate stream directions from a river vector map (Spearfish)
173 v.to.rast input=streams output=streamsdir use=dir
174
175 Calculate slope along path
176 Using slope and aspect maps, compute slope along a bus route (use full
177 NC sample dataset):
178 g.region raster=elevation -p
179 r.slope.aspect elevation=elevation slope=slope aspect=aspect
180 # compute direction of the bus route
181 v.to.rast input=busroute11 type=line output=busroute11_dir use=dir
182 # extract steepest slope values and transform them into slope along path
183 r.mapcalc "route_slope = if(busroute11, slope)"
184 r.mapcalc "route_slope_dir = abs(atan(tan(slope) * cos(aspect - busroute11_dir)))"
185 Slope in degrees along bus route
186
187 Convert a vector polygon map to raster including descriptive labels
188 In this example, the ZIP code vector map is rasterized (North Carolina
189 sample dataset):
190 # rasterize ZIP codes at 50m raster resolution
191 g.region vector=zipcodes_wake res=50 -ap
192 # vector to raster conversion, with category labels
193 v.to.rast input=zipcodes_wake output=myzipcodes use=attr attribute_column="ZIPNUM" label_column="NAME"
194
195 Convert vector points to raster with raster cell binning
196 In this example, the number of schools per raster cell are counted
197 (North Carolina sample dataset):
198 g.copy vector=schools_wake,myschools_wake
199 # set computation region for raster binning
200 g.region vector=myschools_wake res=5000 -p -a
201 # add new column for counting
202 v.db.addcolumn myschools_wake column="value integer"
203 v.db.update myschools_wake column=value value=1
204 # verify attributes
205 v.db.select myschools_wake column=cat,value
206 v.out.ascii input=myschools_wake output=- column=value
207 # export and import on the fly, use 4th column (value) as input
208 v.out.ascii input=myschools_wake output=- column=value | r.in.xyz input=- \
209 z=4 output=schools_wake_aggreg method=sum
210 d.mon wx0
211 d.rast schools_wake_aggreg
212 d.vect schools_wake
213 d.grid 5000
214 Number of schools per raster cell
215
217 db.describe, v.category
218
220 Original code: Michael Shapiro, U.S. Army Construction Engineering
221 Research Laboratory
222 GRASS 6.0 updates: Radim Blazek, ITC-irst, Trento, Italy
223 Stream directions: Jaro Hofierka and Helena Mitasova
224 GRASS 6.3 code cleanup and label support: Brad Douglas
225
227 Available at: v.to.rast source code (history)
228
229 Main index | Vector index | Topics index | Keywords index | Graphical
230 index | Full index
231
232 © 2003-2020 GRASS Development Team, GRASS GIS 7.8.5 Reference Manual
233
234
235
236GRASS 7.8.5 v.to.rast(1)