3
<em>v.overlay</em> allows the user to overlay two vector maps. Features
4
in <b>ainput</b> can be lines or areas and are cut with areas in
5
<b>binput</b>. Simple <i>clipping</i> can be performed with the <b>and</b>
8
If areas in <b>ainput</b> are overlaid with areas in <b>binput</b>,
9
it is sometimes necessary to snap areas of <b>binput</b> to those of
10
<b>ainput</b>, otherwise areas can go missing or many sliver areas
11
can be created. Snapping is enabled by default and can be disabled by
12
setting the <b>snap</b> option to a negative value. Recommended values
13
are between 0.00000001 and 0.0001. Using larger values for snapping can
14
have undesired side-effects, but may sometimes be necessary to get a
15
clean output (see example below). In general, it is recommended to start
16
with a small snapping threshold, gradually increasing the threshold until
17
the result is reasonably clean. Snapping modifies only boundaries in
18
binput, which are snapped to boundaries in ainput. Boundaries in <b>ainput</b>
21
There are 3 links attached to features in output map,
23
<li><b>field 1</b>: link to the new table, new table has 3 columns
25
<li><b>cat</b> - key column linking rows to features
26
<li><b>cata</b> - category of <i>afield</i> from <i>ainput</i>
27
<li><b>catb</b> - category of <i>bfield</i> from <i>binput</i>
29
<li><b>field 2</b>: category of <i>afield</i> from <i>ainput</i>
30
<li><b>field 3</b>: category of <i>bfield</i> from <i>binput</i>
34
If the <i>first</i> number of the <b>olayer</b> option is greater than 0, then the
35
resulting output map has a merged attribute table in the given layer
36
number. The original column names have a prefix (<em>a_</em> and
37
<em>b_</em>) corresponding to <b>ainput</b> and <b>binput</b> map.
39
If the <i>second</i> number of the <b>olayer</b> option is greater than 0, then the
40
categories of <b>ainput</b> in layer <b>alayer</b> are transferred to
41
the output layer with the second number.
43
If the <i>third</i> number of the <b>olayer</b> option is greater than 0, then the
44
categories of <b>binput</b> in layer <em>blayer</em> are transferred to
45
the output layer with the third number.
48
Currently only areas in <b>ainput</b> are supported for the operators
49
<em>or</em> and <em>xor</em>! See also <em><a href="v.select.html">v.select</a></em>.
51
The operator defines what kind of operation will be done. Features are
52
written to output, if the result of an operation <b>ainput</b> operator <b>binput</b>
55
If the <i>first</i> number of the <b>olayer</b> option is greater than 0, then attributes
56
of the tables from <b>ainput</b> and <b>binput</b> are joined into a new table linked
57
to the output map with a new cat column.
59
If the <i>second</i> number of the <b>olayer</b> option is greater than 0, then the
60
attribute table of <b>ainput</b> is copied to the output map.
62
If the <i>third</i> number of the <b>olayer</b> option is greater than 0, then the
63
attribute table of <b>binput</b> is copied to the output map.
66
If <b>atype</b>=auto is given than <em>v.overlay</em> determines
67
feature type for <b>ainput</b> from the first found feature.
70
<p><div class="code"><pre>
71
v.db.connect map=outputmap table=ainput.dbf field=2
72
v.db.connect map=outputmap table=binput.dbf field=3
76
<p><b>Attention:</b> Removing the output map will also delete all tables linked to
77
it! Therefore it is advisable to copy tables from ainput and binput first and
78
connect the copied tables to the output map.-->
82
<h3>Overlay operations: AND, OR, NOT, XOR</h3>
84
Examples based on North Carolina sample dataset:
86
<div class="code"><pre>
87
# creation of simple dataset
88
v.extract input=zipcodes_wake output=poly1 where="cat = 42"
89
v.extract input=urbanarea output=poly2 where="cat = 55"
91
v.overlay ainput=poly1 binput=poly2 operator=and output=poly_1_2_and
92
v.overlay ainput=poly1 binput=poly2 operator=or output=poly_1_2_or
93
v.overlay ainput=poly1 binput=poly2 operator=not output=poly_1_2_not
94
v.overlay ainput=poly1 binput=poly2 operator=xor output=poly_1_2_xor
98
<img src="v_overlay_poly_1_2.png" alt="GRASS v.overlay: input polygons (1 and 2)" border=0>
100
<i>v.overlay operations: original input polygons</i>
104
<img src="v_overlay_poly_1_2_a_o_n_x.png" alt="GRASS v.overlay results: AND, OR, NOT, XOR operations" border=0>
106
<i>v.overlay results of AND, OR, NOT, XOR operations</i>
110
<h3>Polygons overlaid with polygons</h3>
111
<div class="code"><pre>
112
v.overlay ainput=lake binput=province output=lakeXprovince operator=or
115
Polygon union of urban area and Census 2000 areas (North Carolina dataset):
117
<div class="code"><pre>
120
d.vect census_wake2000
123
v.overlay ain=census_wake2000 bin=urbanarea out=urban_census2000 operator=or
125
# show result, graphically zooming a subset
126
g.region n=230400 s=223800 w=655800 e=662400
128
d.vect urban_census2000
130
# show merged attribute table
131
v.db.select urban_census2000 where="cat=108" -v
154
<img src="v_overlay_urbanarea.png" alt="GRASS v.overlay: polygon to polygon union (input 1)" border=1>
155
<img src="v_overlay_census_wake2000.png" alt="GRASS v.overlay: polygon to polygon union (input 2)" border=1>
156
<img src="v_overlay_urban_census2000.png" alt="GRASS v.overlay: polygon to polygon union (result)" border=1>
158
<i>v.overlay: Polygon union (right) of urban area (left) and Census 2000 (middle) areas (North Carolina dataset)</i>
162
As can be seen by the resulting large number of centroids on boundaries,
163
the urban areas do not match exactly the Census 2000 areas. In this case
164
a clean result can be obtained by snapping with a threshold of 0.1 m.
166
<h3>Lines overlaid with polygons</h3>
168
Using the North Carolina sample dataset, we clip the roads map to the area
169
of city of Raleigh, preserving road attributes in layer 1:
170
<div class="code"><pre>
171
g.region vector=zipcodes_wake
173
# extract Raleigh city:
174
v.extract in=zipcodes_wake out=raleigh \
175
where="ZIPNAME = 'RALEIGH'"
177
# clip road network to city polygon:
178
v.overlay ainput=roadsmajor atype=line binput=raleigh \
179
out=roadsmajor_raleigh operator=and \
184
<img src="v_overlay_area_lines.png" alt="GRASS v.overlay: Line to polygon clipping"><br>
185
<table border=0 width=590>
187
<i>v.overlay: Line to polygon clipping</i>
196
<a href="v.db.connect.html">v.db.connect</a>,
197
<a href="v.select.html">v.select</a>,
198
<a href="g.copy.html">g.copy</a>
203
Radim Blazek, ITC-Irst, Trento, Italy<br>
207
<i>Last changed: $Date: 2014-12-19 22:55:37 +0100 (Fri, 19 Dec 2014) $</i>