<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FWrobell</id>
	<title>GRASS-Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FWrobell"/>
	<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/wiki/Special:Contributions/%E2%9A%A0%EF%B8%8FWrobell"/>
	<updated>2026-05-25T15:43:34Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=7395</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=7395"/>
		<updated>2008-08-19T23:44:08Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Road Network Data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector map using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on these roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector map, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data change or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which references road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat,&lt;br /&gt;
        rn.id as id,&lt;br /&gt;
        r.route_id as route_id&lt;br /&gt;
    from route r&lt;br /&gt;
        left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
Sample data can be downloaded using one of the links&lt;br /&gt;
* http://entropy.echelon.pl/wrobell/grass/gvl-0.1.zip&lt;br /&gt;
* http://wrobell.it-zone.org/grass/gvl-0.1.zip&lt;br /&gt;
&lt;br /&gt;
The archive contains basic relational database  and Grass&lt;br /&gt;
data based on Spearfish data&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file with tables and view described above&lt;br /&gt;
* vector map '''roads''' containing road network map data&lt;br /&gt;
&lt;br /&gt;
To start processing sample data unpack the archive and start Grass&lt;br /&gt;
within PERMANENT location&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' provided with sample data has one layer of categories and&lt;br /&gt;
it is not connected to any database table. This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
To connect vector map with two layers of data, vector categories&lt;br /&gt;
have to be populated into these layers using following commands&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, detailed information&lt;br /&gt;
describing the process is provided below.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required,&lt;br /&gt;
it has to be removed using command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=7394</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=7394"/>
		<updated>2008-08-19T23:41:09Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Appendix: Creating Tutorial's Road Network and Routes Data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector map using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on these roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector map, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data change or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which references road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat,&lt;br /&gt;
        rn.id as id,&lt;br /&gt;
        r.route_id as route_id&lt;br /&gt;
    from route r&lt;br /&gt;
        left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
Sample data can be downloaded using one of the links&lt;br /&gt;
* http://entropy.echelon.pl/wrobell/grass/gvl-0.1.zip&lt;br /&gt;
* http://wrobell.it-zone.org/grass/gvl-0.1.zip&lt;br /&gt;
&lt;br /&gt;
The archive contains basic relational database  and Grass&lt;br /&gt;
data based on Spearfish data&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file with tables and view described above&lt;br /&gt;
* vector map '''roads''' containing road network map data&lt;br /&gt;
&lt;br /&gt;
To start processing sample data unpack the archive and start Grass&lt;br /&gt;
within PERMANENT location&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' provided with sample data has one layer of categories and&lt;br /&gt;
it is not connected to any database table. This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
To connect vector map with two layers of data, vector categories&lt;br /&gt;
have to be populated into these layers using following commands&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, detailed information&lt;br /&gt;
describing the process is provided below.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=7393</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=7393"/>
		<updated>2008-08-19T23:39:49Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector map using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on these roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector map, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data change or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which references road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat,&lt;br /&gt;
        rn.id as id,&lt;br /&gt;
        r.route_id as route_id&lt;br /&gt;
    from route r&lt;br /&gt;
        left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
Sample data can be downloaded using one of the links&lt;br /&gt;
* http://entropy.echelon.pl/wrobell/grass/gvl-0.1.zip&lt;br /&gt;
* http://wrobell.it-zone.org/grass/gvl-0.1.zip&lt;br /&gt;
&lt;br /&gt;
The archive contains basic relational database  and Grass&lt;br /&gt;
data based on Spearfish data&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file with tables and view described above&lt;br /&gt;
* vector map '''roads''' containing road network map data&lt;br /&gt;
&lt;br /&gt;
To start processing sample data unpack the archive and start Grass&lt;br /&gt;
within PERMANENT location&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' provided with sample data has one layer of categories and&lt;br /&gt;
it is not connected to any database table. This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
To connect vector map with two layers of data, vector categories&lt;br /&gt;
have to be populated into these layers using following commands&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=7392</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=7392"/>
		<updated>2008-08-19T23:37:15Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Sample Data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector map using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on these roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector map, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data change or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which references road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat,&lt;br /&gt;
        rn.id as id,&lt;br /&gt;
        r.route_id as route_id&lt;br /&gt;
    from route r&lt;br /&gt;
        left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
Sample data can be downloaded using one of the links&lt;br /&gt;
* http://entropy.echelon.pl/wrobell/grass/gvl-0.1.zip&lt;br /&gt;
* http://wrobell.it-zone.org/grass/gvl-0.1.zip&lt;br /&gt;
&lt;br /&gt;
The archive contains basic relational database  and Grass&lt;br /&gt;
data based on Spearfish data&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file with tables and view described above&lt;br /&gt;
* vector map '''roads''' containing road network map data&lt;br /&gt;
&lt;br /&gt;
To start processing sample data unpack the archive and start Grass&lt;br /&gt;
within PERMANENT location&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=7391</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=7391"/>
		<updated>2008-08-19T23:28:39Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Sample Data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector map using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on these roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector map, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data change or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which references road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat,&lt;br /&gt;
        rn.id as id,&lt;br /&gt;
        r.route_id as route_id&lt;br /&gt;
    from route r&lt;br /&gt;
        left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
Sample data can be downloaded from [[Media:gvl-0.1.tar.gz]].&lt;br /&gt;
The archive contains basic relational database  and Grass&lt;br /&gt;
data based on Spearfish data&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file with tables and view described above&lt;br /&gt;
* vector map '''roads''' containing road network map data&lt;br /&gt;
&lt;br /&gt;
To start processing sample data unpack the archive and start Grass&lt;br /&gt;
within PERMANENT location&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6838</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6838"/>
		<updated>2008-06-08T08:33:56Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Datamodel Discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector map using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on these roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector map, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data change or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which references road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat,&lt;br /&gt;
        rn.id as id,&lt;br /&gt;
        r.route_id as route_id&lt;br /&gt;
    from route r&lt;br /&gt;
        left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File [[Media:gvl-0.1.tar.gz]] attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6837</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6837"/>
		<updated>2008-06-08T08:32:22Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Datamodel Discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector map using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on these roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector map, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data change or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which references road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File [[Media:gvl-0.1.tar.gz]] attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6836</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6836"/>
		<updated>2008-06-08T08:30:50Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Problem Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector map using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on these roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector map, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data change or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File [[Media:gvl-0.1.tar.gz]] attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6835</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6835"/>
		<updated>2008-06-08T08:28:41Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector map using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File [[Media:gvl-0.1.tar.gz]] attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6834</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6834"/>
		<updated>2008-06-07T23:27:59Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Footnotes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File [[Media:gvl-0.1.tar.gz]] attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6813</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6813"/>
		<updated>2008-06-03T22:22:57Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Routes Data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File [[Media:gvl-0.1.tar.gz]] attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
== Footnotes ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6812</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6812"/>
		<updated>2008-06-03T22:22:07Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File [[Media:gvl-0.1.tar.gz]] attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6811</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6811"/>
		<updated>2008-06-03T22:21:46Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File [[Media:gvl-0.1.tar.gz]] attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6810</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6810"/>
		<updated>2008-06-03T22:20:55Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
&amp;lt;ref&amp;gt;http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File [[Media:gvl-0.1.tar.gz]] attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6744</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6744"/>
		<updated>2008-05-29T22:27:05Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Sample Data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File [[Media:gvl-0.1.tar.gz]] attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6743</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6743"/>
		<updated>2008-05-29T22:22:25Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Sample Data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File [[Media:gvl-0.1.zip]] attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6742</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6742"/>
		<updated>2008-05-29T22:17:59Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Routes Data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer, roads segments belonging to first route,&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6741</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6741"/>
		<updated>2008-05-29T22:16:47Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Routes Data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
Routes data were created using '''d.what.vect''' command.&lt;br /&gt;
Road network vector map '''roads''' has to be displayed&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
&lt;br /&gt;
Now, it can be queried for data. Run&lt;br /&gt;
    $ d.what.vect -t map=roads &amp;gt; route-01.txt&lt;br /&gt;
Using mouse pointer roads segments belonging to first route&lt;br /&gt;
can be identified. When done, file '''route.txt''' can be&lt;br /&gt;
processed with '''awk''' or other tool to extract road segment&lt;br /&gt;
information, which can be easily uploaded to database.&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6740</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6740"/>
		<updated>2008-05-29T22:10:50Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Road Network Data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
Finally, vector map '''roads''' is being disconnected from road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=road&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6739</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6739"/>
		<updated>2008-05-29T22:09:14Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Road Network Data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector map are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6738</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6738"/>
		<updated>2008-05-29T22:08:38Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Appendix: Creating Tutorial's Road Network and Routes Data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
Sample data for this tutorial were extracted from Spearfish data.&lt;br /&gt;
As it was quite interesting excersise, below detailed information&lt;br /&gt;
is provided describing the process.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''roads''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=roads option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector map '''roads''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f roads&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be populated with categories and road segment identifiers.&lt;br /&gt;
First, road network table has to be connected to vector map&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Now, it is possible to upload categories of vector map '''roads''' into road network table&lt;br /&gt;
    $ v.to.db map=roads option=cat&lt;br /&gt;
&lt;br /&gt;
Road network data usually is provided with some road segment identifiers.&lt;br /&gt;
The identifiers are usually set by vendor of road network data but they&lt;br /&gt;
are missing in case of Spearfish data. Therefore, for the purpose of this tutorial&lt;br /&gt;
they will be generated from categories of vector map '''roads'''. It can be done easily&lt;br /&gt;
with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6737</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6737"/>
		<updated>2008-05-29T21:55:09Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector map '''roads''' has one layer of categories and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6736</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6736"/>
		<updated>2008-05-29T21:53:34Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector '''roads''' has one layer and it is not connected to any database table.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6735</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6735"/>
		<updated>2008-05-29T21:51:39Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Problem Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector '''roads''' has one layer and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6734</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6734"/>
		<updated>2008-05-29T21:46:02Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Separate Route Map */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector '''roads''' has one layer and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
To display vector '''r4''', '''layer''' parameter has to be used as routing&lt;br /&gt;
information is still in second layer&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=r4 layer=2&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6733</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6733"/>
		<updated>2008-05-29T21:43:44Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Using Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector '''roads''' has one layer and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.mon x0&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
==== Creating Separate Route Map ====&lt;br /&gt;
To create separate vector map of route number 4&lt;br /&gt;
    $ v.extract -t input=roads layer=2 output=r4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
Please note '''-t''' parameter, which forces Grass to ''not'' copy database&lt;br /&gt;
table, which can be very costly operation.&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6732</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6732"/>
		<updated>2008-05-29T21:38:12Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Using Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector '''roads''' has one layer and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Almost all Grass commands accept '''layer''' parameter, which determines&lt;br /&gt;
layer to be used by a command. Below, some examples are provided.&lt;br /&gt;
&lt;br /&gt;
==== Displaying ====&lt;br /&gt;
To display road network map and routes number 1 and 4&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=roads layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6731</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6731"/>
		<updated>2008-05-29T21:33:05Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector '''roads''' has one layer and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, database tables have to be connected to Grass vector map using '''v.db.connect'''&lt;br /&gt;
command&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
Road network table is connected as first layer and route information as second layer.&lt;br /&gt;
&lt;br /&gt;
=== Using Layers ===&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6730</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6730"/>
		<updated>2008-05-29T21:30:22Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector '''roads''' has one layer and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=roads driver=sqlite database=gvl.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=roads layer=2 driver=sqlite database=gvl.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    Vector map &amp;lt;roads&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;gvl.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6729</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6729"/>
		<updated>2008-05-29T21:27:15Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector '''roads''' has one layer and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
    Layer: 2&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6728</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6728"/>
		<updated>2008-05-29T21:25:02Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector '''roads''' has one layer and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vector categories have to be populated into two layers&lt;br /&gt;
(or more if required)&lt;br /&gt;
    $ v.category --o input=roads layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=roads&lt;br /&gt;
    $ g.rename vect=tmprn,roads&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6727</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6727"/>
		<updated>2008-05-29T21:23:23Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Grass Vector Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector '''roads''' has one layer and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1        825&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1        825&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6726</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6726"/>
		<updated>2008-05-29T21:19:46Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Grass Vector Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
=== Sample Data ===&lt;br /&gt;
File gvl-0.1.zip attached to this tutorial contains Grass data based on Spearfish&lt;br /&gt;
data and basic relational database&lt;br /&gt;
* road network Grass vector map '''roads'''&lt;br /&gt;
* '''gvl.sqlite''' file is SQLite relational database file, which has tables and view described above&lt;br /&gt;
&lt;br /&gt;
Unzip the file with sample data, enter its directory and start Grass&lt;br /&gt;
&lt;br /&gt;
    $ unzip gvl-0.1.zip&lt;br /&gt;
    $ cd gvl-0.1&lt;br /&gt;
    $ grass PERMANENT&lt;br /&gt;
&lt;br /&gt;
=== Creating Layers ===&lt;br /&gt;
Vector '''roads''' has one layer and it is not connected to any database table.&lt;br /&gt;
This can be checked with commands&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=roads&lt;br /&gt;
    ERROR: Database connection for map &amp;lt;roads&amp;gt; is not defined in DB file&lt;br /&gt;
&lt;br /&gt;
    $ v.category option=report input=roads&lt;br /&gt;
    Layer: 1&lt;br /&gt;
    type       count        min        max&lt;br /&gt;
    point          0          0          0&lt;br /&gt;
    line         825          1          5&lt;br /&gt;
    boundary       0          0          0&lt;br /&gt;
    centroid       0          0          0&lt;br /&gt;
    area           0          0          0&lt;br /&gt;
    all          825          1          5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6725</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6725"/>
		<updated>2008-05-29T20:46:14Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
* routes to road network view exists to associate route information with Grass vector data&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
== Appendix: Creating Tutorial's Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6724</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6724"/>
		<updated>2008-05-29T20:43:01Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Datamodel Discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to have at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Routes table shall consist of &lt;br /&gt;
* route identifier&lt;br /&gt;
* id of road segment driven on a route, which reference road segment id in road network table&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view, i.e.&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
* routes to road network view exists to associate route information with Grass vector data&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6723</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6723"/>
		<updated>2008-05-29T20:18:47Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Datamode Discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamodel Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
* routes to road network view exists to associate route information with Grass vector data&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6722</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6722"/>
		<updated>2008-05-29T20:04:21Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Datamode Discussion ==&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
* routes to road network view exists to associate route information with Grass vector data&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6702</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6702"/>
		<updated>2008-05-23T00:09:39Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers&lt;br /&gt;
:http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Database Tables ===&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
* routes to road network view exists to associate route information with Grass vector data&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6701</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6701"/>
		<updated>2008-05-23T00:08:20Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Grass Vector Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;Vector data processing in GRASS GIS, http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Database Tables ===&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
* routes to road network view exists to associate route information with Grass vector data&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
References: &amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6700</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6700"/>
		<updated>2008-05-23T00:07:34Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&amp;lt;ref&amp;gt;Vector data processing in GRASS GIS, http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Database Tables ===&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
* routes to road network view exists to associate route information with Grass vector data&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
References: &amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6699</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6699"/>
		<updated>2008-05-23T00:06:16Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&amp;lt;ref&amp;gt;Vector data processing in GRASS GIS.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Database Tables ===&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
* routes to road network view exists to associate route information with Grass vector data&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
which is rendered as on the map presented below&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
References: &amp;lt;references/&amp;gt;&lt;br /&gt;
http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6698</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6698"/>
		<updated>2008-05-23T00:04:42Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers.&amp;lt;ref&amp;gt;Vector data processing in GRASS GIS.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Database Tables ===&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
* routes to road network view exists to associate route information with Grass vector data&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
which is rendered as on the map presented below&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6697</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6697"/>
		<updated>2008-05-23T00:03:49Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management,&lt;br /&gt;
categories of vector features and vector layers, see&lt;br /&gt;
&amp;lt;ref&amp;gt;Vector data processing in GRASS GIS&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Database Tables ===&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
* routes to road network view exists to associate route information with Grass vector data&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
which is rendered as on the map presented below&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6696</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6696"/>
		<updated>2008-05-23T00:01:35Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Grass Vector Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management.&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Database Tables ===&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
* routes to road network view exists to associate route information with Grass vector data&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and route information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
which is rendered as on the map presented below&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6695</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6695"/>
		<updated>2008-05-22T23:59:32Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Database Tables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management.&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Database Tables ===&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table also has to provide vector category information. This can be&lt;br /&gt;
realized with a SQL view&lt;br /&gt;
    create view route_rn as&lt;br /&gt;
    select rn.cat as cat, rn.id as id, r.route_id as route_id&lt;br /&gt;
    from route r left join road_network rn on r.rn_id = rn.id;&lt;br /&gt;
&lt;br /&gt;
Above tables and view allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and routes information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
which is rendered as on the map presented below&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6694</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6694"/>
		<updated>2008-05-22T23:55:44Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Grass Vector Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management.&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Database Tables ===&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Above tables allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and routes information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and routes no 1 and 4 can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
which is rendered as on the map presented below&lt;br /&gt;
[[Image:routes.png|frame|Road network and routes 1 and 4]]&lt;br /&gt;
&lt;br /&gt;
http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6693</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6693"/>
		<updated>2008-05-22T23:53:32Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Grass Vector Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management.&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Database Tables ===&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Above tables allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and routes information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and all routes can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
[[Image:routes.png|frame|Road network and two routes]]&lt;br /&gt;
&lt;br /&gt;
http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6692</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6692"/>
		<updated>2008-05-22T23:53:12Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Grass Vector Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management.&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Database Tables ===&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Above tables allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and routes information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and all routes can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
     [[Image:routes.png|frame|Road network and two routes]]&lt;br /&gt;
&lt;br /&gt;
http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=File:Routes.png&amp;diff=6691</id>
		<title>File:Routes.png</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=File:Routes.png&amp;diff=6691"/>
		<updated>2008-05-22T23:43:50Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: uploaded a new version of &amp;quot;Image:Routes.png&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6690</id>
		<title>GRASS Vector Layers</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Vector_Layers&amp;diff=6690"/>
		<updated>2008-05-22T23:42:57Z</updated>

		<summary type="html">&lt;p&gt;⚠️Wrobell: /* Creating Grass Vector Layers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Grass documentation provides basic information about vector attribute management.&lt;br /&gt;
categories of vector features and vector layers.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to show how to create, manipulate and&lt;br /&gt;
display different layers of a vector using relational database.&lt;br /&gt;
&lt;br /&gt;
== Problem Description ==&lt;br /&gt;
An organization provides information about routes to be driven&lt;br /&gt;
by drivers. The organization's database consists of&lt;br /&gt;
* roads (road network)&lt;br /&gt;
* routes driven on that roads&lt;br /&gt;
&lt;br /&gt;
Simple approach can be taken to present the routes to drivers. &lt;br /&gt;
For every route a vector map could be created and overlayed over&lt;br /&gt;
the road network vector, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=route01 color=green width=2&lt;br /&gt;
&lt;br /&gt;
Above idea has a major flaw. If route data changes or new route is added&lt;br /&gt;
then vector maps has to be regenerated or removed.&lt;br /&gt;
&lt;br /&gt;
Assuming that route network and routes data are stored in relational database,&lt;br /&gt;
the database tables can be linked to road network map as its layers.&lt;br /&gt;
Such layer information could be utilized to display maps, i.e.&lt;br /&gt;
&lt;br /&gt;
    $ d.vect map=roads&lt;br /&gt;
    $ d.vect map=roads layer=2 where=&amp;quot;route_id=1&amp;quot; color=green width=2&lt;br /&gt;
&lt;br /&gt;
The tutorial reuses road network provided with Spearfish data. To solve&lt;br /&gt;
problem defined above, the roads data and sample routes needs to be prepared.&lt;br /&gt;
This is described in next section.&lt;br /&gt;
&lt;br /&gt;
== Road Network and Routes Data ==&lt;br /&gt;
&lt;br /&gt;
=== Database Tables ===&lt;br /&gt;
Relation database should contain two tables&lt;br /&gt;
* road network table&lt;br /&gt;
* driven routes table&lt;br /&gt;
&lt;br /&gt;
Road network table has to contain at least two columns&lt;br /&gt;
* road segment id usually provided with road network data by vendor&lt;br /&gt;
* vectory category required by Grass to identify vector features&lt;br /&gt;
&lt;br /&gt;
Road network table can be defined like&lt;br /&gt;
    create table road_network (&lt;br /&gt;
        cat integer,&lt;br /&gt;
        id integer   -- road segment id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Routes table contains route identifier and id of road segment driven&lt;br /&gt;
on a route&lt;br /&gt;
    create table route (&lt;br /&gt;
        route_id integer,&lt;br /&gt;
        rn_id integer    -- references road_network.id&lt;br /&gt;
    );&lt;br /&gt;
&lt;br /&gt;
Above tables allow to provide road network and driven routes information. They&lt;br /&gt;
can be more complicated depending on application but for purpose of this tutorial&lt;br /&gt;
such minimal approach is being kept.&lt;br /&gt;
&lt;br /&gt;
=== Road Network Data ===&lt;br /&gt;
&lt;br /&gt;
Spearfish data provides road network map in '''roads''' vector.&lt;br /&gt;
It contains few hundred vector lines - road network segments.&lt;br /&gt;
Data associated with this vector are very simple and they have to be&lt;br /&gt;
extended&lt;br /&gt;
* unique category id for every vector road segment needs to generated&lt;br /&gt;
* unique id has to be assigned to every road segment&lt;br /&gt;
&lt;br /&gt;
Below, vector '''rn''' is created with every vector line having unique&lt;br /&gt;
category&lt;br /&gt;
&lt;br /&gt;
    $ v.category --o in=roads out=tmpmap option=del&lt;br /&gt;
    $ v.category --o in=tmpmap out=rn option=add&lt;br /&gt;
    $ g.remove vect=tmpmap&lt;br /&gt;
&lt;br /&gt;
Vector '''rn''' is connected to DBF file, which is no longer required. Therefore&lt;br /&gt;
it has to be removed.&lt;br /&gt;
&lt;br /&gt;
    $ v.db.droptable -f rn&lt;br /&gt;
&lt;br /&gt;
Road network table needs to be associated with road network vector&lt;br /&gt;
(SQLite driver is used with database located in '''data.sqlite''' file; of course,&lt;br /&gt;
any other RDBMS can be used)&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
&lt;br /&gt;
Categories of vector '''rn''' has to be uploaded into road network table&lt;br /&gt;
&lt;br /&gt;
    $ v.to.db map=rn option=cat&lt;br /&gt;
&lt;br /&gt;
As it was said above, road network data usually is provided with some road&lt;br /&gt;
segment identifiers. There is no road segment ids in case of Spearfish data.&lt;br /&gt;
Therefore, for the purpose of this tutorial they will be generated from categories&lt;br /&gt;
of vector '''rn'''. It can be done easily with SQL query&lt;br /&gt;
&lt;br /&gt;
    update road_network set id = cat;&lt;br /&gt;
&lt;br /&gt;
=== Routes Data ===&lt;br /&gt;
SQL queries below create four sample routes driven on road network provided&lt;br /&gt;
in Spearfish data.&lt;br /&gt;
&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 411);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 412);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (1, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 410);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 413);&lt;br /&gt;
    insert into route (route_id, rn_id) values (2, 414);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 10);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 408);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 409);&lt;br /&gt;
    insert into route (route_id, rn_id) values (3, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 407);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 415);&lt;br /&gt;
    insert into route (route_id, rn_id) values (4, 9);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating Grass Vector Layers ==&lt;br /&gt;
&lt;br /&gt;
Previous section described in detail how to prepare sample data&lt;br /&gt;
to illustrate problem defined in this tutorial. To summarize&lt;br /&gt;
* road network vector map exists in Grass&lt;br /&gt;
* road network database table is associated with road network map; it has columns&lt;br /&gt;
** id - identifies road segment id&lt;br /&gt;
** cat - identifies road segment in Grass vector map&lt;br /&gt;
* routes table is created, it has route id and road segment id columns; four routes are defined&lt;br /&gt;
&lt;br /&gt;
Route network table is connected as first layer to '''rn''' vector.&lt;br /&gt;
This can be checked with command&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
&lt;br /&gt;
Let's disconnect vector '''rn''' from its first layer&lt;br /&gt;
&lt;br /&gt;
    $ v.db.connect -d map=rn layer=1&lt;br /&gt;
&lt;br /&gt;
Now, without copying database table, vector categories can be populated&lt;br /&gt;
into two layers (or more if required)&lt;br /&gt;
    $ v.category --o input=rn layer=2 output=tmprn&lt;br /&gt;
    $ g.remove vect=rn&lt;br /&gt;
    $ g.rename vect=tmprn,rn&lt;br /&gt;
'''Above step is very important. Vector categories needs to be populated in all layers.'''&lt;br /&gt;
&lt;br /&gt;
Road network table can be reconnected as first layer&lt;br /&gt;
and routes information as second layer&lt;br /&gt;
    $ v.db.connect -o map=rn driver=sqlite database=data.sqlite table=road_network&lt;br /&gt;
    $ v.db.connect -o map=rn layer=2 driver=sqlite database=data.sqlite table=route_rn&lt;br /&gt;
    $ v.db.connect -p map=rn&lt;br /&gt;
    Vector map &amp;lt;rn&amp;gt; is connected by:&lt;br /&gt;
    layer &amp;lt;1&amp;gt; table &amp;lt;road_network&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
    layer &amp;lt;2&amp;gt; table &amp;lt;route_rn&amp;gt; in database &amp;lt;data.sqlite&amp;gt; through driver &amp;lt;sqlite&amp;gt; with key &amp;lt;cat&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Road network map and all routes can be displayed&lt;br /&gt;
    $ d.vect map=rn&lt;br /&gt;
    $ d.vect map=rn layer=2 color=green width=8 where='route_id=1'&lt;br /&gt;
    $ d.vect map=rn layer=2 color=red width=4 where='route_id=4'&lt;br /&gt;
&lt;br /&gt;
           [[Image:routes.png|frame|Road network and two routes]]&lt;br /&gt;
&lt;br /&gt;
http://grass.osgeo.org/grass63/manuals/html63_user/vectorintro.html&lt;/div&gt;</summary>
		<author><name>⚠️Wrobell</name></author>
	</entry>
</feed>