1v.net.alloc(1) GRASS GIS User's Manual v.net.alloc(1)
2
3
4
6 v.net.alloc - Allocates subnets for nearest centers.
7 Center node must be opened (costs >= 0). Costs of center node are used
8 in calculation.
9
11 vector, network, cost allocation
12
14 v.net.alloc
15 v.net.alloc --help
16 v.net.alloc [-tgu] input=name output=name [method=string] cen‐
17 ter_cats=range arc_layer=string arc_type=string[,string,...]
18 node_layer=string [arc_column=name] [arc_backward_column=name]
19 [node_column=name] [turn_layer=string] [turn_cat_layer=string]
20 [--overwrite] [--help] [--verbose] [--quiet] [--ui]
21
22 Flags:
23 -t
24 Use turntable
25
26 -g
27 Use geodesic calculation for longitude-latitude locations
28
29 -u
30 Create unique categories and attribute table
31 Default: same category like nearest center
32
33 --overwrite
34 Allow output files to overwrite existing files
35
36 --help
37 Print usage summary
38
39 --verbose
40 Verbose module output
41
42 --quiet
43 Quiet module output
44
45 --ui
46 Force launching GUI dialog
47
48 Parameters:
49 input=name [required]
50 Name of input vector map
51 Or data source for direct OGR access
52
53 output=name [required]
54 Name for output vector map
55
56 method=string
57 Use costs from centers or costs to centers
58 Options: from, to
59 Default: from
60
61 center_cats=range [required]
62 Category values
63 Categories of centers (points on nodes) to which net will be allo‐
64 cated, layer for this categories is given by nlayer option
65
66 arc_layer=string [required]
67 Arc layer
68 Vector features can have category values in different layers. This
69 number determines which layer to use. When used with direct OGR
70 access this is the layer name.
71 Default: 1
72
73 arc_type=string[,string,...]Â [required]
74 Arc type
75 Input feature type
76 Options: line, boundary
77 Default: line,boundary
78
79 node_layer=string [required]
80 Node layer
81 Vector features can have category values in different layers. This
82 number determines which layer to use. When used with direct OGR
83 access this is the layer name.
84 Default: 2
85
86 arc_column=name
87 Arc forward/both direction(s) cost column (number)
88
89 arc_backward_column=name
90 Arc backward direction cost column (number)
91
92 node_column=name
93 Node cost column (number)
94
95 turn_layer=string
96 Layer with turntable
97 Relevant only with -t flag
98 Default: 3
99
100 turn_cat_layer=string
101 Layer with unique categories used in turntable
102 Relevant only with -t flag
103 Default: 4
104
106 v.net.alloc allocates subnets for nearest centers. Center nodes must be
107 opened (costs >= 0). Costs of center nodes are used in the calculation.
108
109 Costs may be either line lengths, or attributes saved in a database ta‐
110 ble. These attribute values are taken as costs of whole segments, not
111 as costs to traverse a length unit (e.g. meter) of the segment. For
112 example, if the speed limit is 100 km / h, the cost to traverse a 10 km
113 long road segment must be calculated as
114 length / speed = 10 km / (100 km/h) = 0.1 h.
115 Supported are cost assignments for both arcs and nodes, and also dif‐
116 ferent costs for both directions of a vector line. For areas, costs
117 will be calculated along boundary lines.
118
119 The input vector needs to be prepared with v.net operation=connect in
120 order to connect points representing center nodes to the network.
121
122 The nearest center can be determined using either costs from the near‐
123 est center or costs to the nearest center with option method. See exam‐
124 ple below.
125
126 By default, the category value of the nearest center is used as cate‐
127 gory value for output lines. With the -u flag, output lines become
128 unique categories and an attribute table is created with the fields
129 cat, ocat, center. The ocat field holds the original line category in
130 arc_layer and the center field holds the center category in node_layer.
131 Additionally, original line categories are copied from the input
132 arc_layer to layer 2 in the output, together with any attribute table.
133
134 Application of flag -t enables a turntable support. This flag requires
135 additional parameters turn_layer and turn_cat_layer that are otherwise
136 ignored. The turntable allows to model e.g. traffic code, where some
137 turns may be prohibited. This means that the input layer is expanded by
138 turntable with costs of every possible turn on any possible node
139 (intersection) in both directions. Turntable can be created by the
140 v.net module. For more information about turns in the vector network
141 analyses see wiki page.
142
144 Nodes and arcs can be closed using cost = -1.
145
146 Center nodes can also be assigned to vector nodes using wxGUI vector
147 digitizer.
148
150 1. Subnetwork allocation using distance:
151
152 2. Subnetwork allocation using traveling time:
153
154 Example 1: Calculating subnets for 3 center nodes using distances
155 # Spearfish
156 # center nodes:
157 echo "591235.5|4926306.62|1
158 596591.8|4917042.5|2
159 602722.9|4923544.2|3" | v.in.ascii in=- out=centernodes
160 g.copy vect=roads,myroads
161 # connect points to network
162 v.net myroads points=centernodes out=myroads_net op=connect thresh=200
163 # allocate, specifying range of center cats (easier to catch all):
164 v.net.alloc myroads_net out=myroads_net_alloc center_cats=1-100000 node_layer=2
165 # report categories
166 v.category myroads_net_alloc option=report
167 To display the result, run for example:
168 # show result
169 g.region vector=myroads_net
170 d.mon x0
171 d.vect myroads_net layer=1
172 # the result has to be selected by category number of the relevant node:
173 d.vect myroads_net_alloc cat=1 col=red layer=1
174 d.vect myroads_net_alloc cat=2 col=green layer=1
175 d.vect myroads_net_alloc cat=3 col=yellow layer=1
176 # center nodes
177 d.vect myroads_net col=red icon=basic/triangle fcol=green size=12 layer=2
178
179 Example 2: Calculating subnets for 3 center nodes using traveling time
180 # Spearfish
181 # center nodes:
182 echo "591235.5|4926306.62|1
183 596591.8|4917042.5|2
184 602722.9|4923544.2|3" | v.in.ascii in=- out=centernodes
185 g.copy vect=roads,myroads
186 # create lines map connecting points to network
187 v.net myroads points=centernodes out=myroads_net op=connect thresh=500 arc_layer=1 node_layer=2
188 # set up costs
189 # create unique categories for each road in layer 3
190 v.category in=myroads_net out=myroads_net_time opt=add cat=1 layer=3 type=line
191 # add new table for layer 3
192 v.db.addtable myroads_net_time layer=3 col="cat integer,label varchar(43),length double precision,speed double precision,cost double precision,bcost double precision"
193 # copy road type to layer 3
194 v.to.db myroads_net_time layer=3 qlayer=1 opt=query qcolumn=label columns=label
195 # upload road length in miles
196 v.to.db myroads_net_time layer=3 type=line option=length col=length unit=miles
197 # set speed limits in miles / hour
198 v.db.update myroads_net_time layer=3 col=speed val="5.0"
199 v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label=’interstate’"
200 v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label=’primary highway, hard surface’"
201 v.db.update myroads_net_time layer=3 col=speed val="50.0" where="label=’secondary highway, hard surface’"
202 v.db.update myroads_net_time layer=3 col=speed val="25.0" where="label=’light-duty road, improved surface’"
203 v.db.update myroads_net_time layer=3 col=speed val="5.0" where="label=’unimproved road’"
204 # define traveling costs as traveling time in minutes:
205 # set forward costs
206 v.db.update myroads_net_time layer=3 col=cost val="length / speed * 60"
207 # set backward costs
208 v.db.update myroads_net_time layer=3 col=bcost val="length / speed * 60"
209 # subnetwork allocation with fastest paths
210 v.net.alloc in=myroads_net_time arc_layer=3 node_layer=2 arc_column=cost arc_backward_column=bcost out=myroads_net_alloc_time center_cats=1-3
211 To display the result, run for example:
212 # show result
213 g.region vector=myroads_net
214 d.mon x0
215 d.vect myroads_net type=line layer=1
216 # the result has to be selected by category number of the relevant node:
217 d.vect myroads_net_alloc_time cat=1 col=red layer=1
218 d.vect myroads_net_alloc_time cat=2 col=green layer=1
219 d.vect myroads_net_alloc_time cat=3 col=yellow layer=1
220 # center nodes
221 d.vect myroads_net_time col=red icon=basic/triangle fcol=green size=12 type=point layer=2
222
223 Example 3: Differences between costs from centers and costs to centers
224 Each lane of the two-lane road is a one-way road.
225
226 1. Subnetwork allocation from centers:
227
228 A center reaches any point following the one-way lanes.
229
230 2. Subnetwork allocation to centers:
231
232 Any node reaches reaches the nearest center following the one-way
233 lanes.
234
235 In case of an accident, the ambulance should come from the nearest
236 ’from’ hospital and go to the nearest ’to’ hospital.
237 # North Carolina
238 # center nodes are hospitals:
239 # connect hospitals to streets as layer 2
240 v.net input=streets_wake points=hospitals output=streets_hospitals operation=connect thresh=400 arc_layer=1 node_layer=2
241 v.to.db map=streets_hospitals layer=1 type=line option=cat columns=cat
242 # close oneway roads
243 v.db.update map=streets_hospitals column=TF_COST value=-1 where="ONE_WAY = ’FT’"
244 v.db.update map=streets_hospitals column=FT_COST value=-1 where="ONE_WAY = ’TF’"
245 # add costs to newly created lines
246 v.db.update map=streets_hospitals column=TF_COST value=0 where="cat > 49746"
247 v.db.update map=streets_hospitals column=FT_COST value=0 where="cat > 49746"
248 # from centers
249 v.net.alloc in=streets_hospitals out=streets_hospitals_alloc_from center_cats=1-10000 arc_column=FT_COST arc_backward_column=TF_COST
250 # to centers
251 v.net.alloc in=streets_hospitals out=streets_hospitals_alloc_to method=to center_cats=1-10000 arc_column=FT_COST arc_backward_column=TF_COST
252
254 d.path, v.net, v.net.iso, v.net.path, v.net.steiner, v.net.salesman
255
257 Radim Blazek, ITC-Irst, Trento, Italy
258 Documentation: Markus Neteler, Markus Metz
259
260 TURNS SUPPORT
261 The turns support was implemnented as part of GRASS GIS turns cost
262 project at Czech Technical University in Prague, Czech Republic.
263 Eliska Kyzlikova, Stepan Turek, Lukas Bocan and Viera Bejdova partici‐
264 pated at the project. Implementation: Stepan Turek Documentation:
265 Lukas Bocan Mentor: Martin Landa
266
268 Available at: v.net.alloc source code (history)
269
270 Main index | Vector index | Topics index | Keywords index | Graphical
271 index | Full index
272
273 © 2003-2020 GRASS Development Team, GRASS GIS 7.8.5 Reference Manual
274
275
276
277GRASS 7.8.5 v.net.alloc(1)