<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=windows-1255"
http-equiv="Content-Type">
<title></title>
</head>
<body bidimailui-charset-is-forced="true"
bidimailui-detected-decoding-type="preferred-charset" text="#000000"
bgcolor="#ffffff">
On 05/03/2011 07:29 AM, <a class="moz-txt-link-abbreviated" href="mailto:rvanderweide@worldbank.org">rvanderweide@worldbank.org</a> wrote:
<blockquote
cite="mid:OF59DC5BB8.AD325784-ON85257885.0018A2AF-85257885.0018A2B1@worldbank.org"
type="cite"><font face="Default Sans
Serif,Verdana,Arial,Helvetica,sans-serif" size="2">
<p style="margin: 0px;">Dear GRASS users,</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">I use the Windows version of GRASS
6.4.1.</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">I wish to join the attribute table from
my shapefile to a tabe from a CSV file -- so i can put the
columns from the CSV file on the map.</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">v.db.join states that it does not
support DBF. However, by default GRASS 6.4.1 stores tables in
DBF. And when i connect to a SQLite database before i import
my shapefile results in an error.</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">What is the easiest way of achieving the
above? Find another way to connect to a SQLite database
before importing my shapefile and tables? Or, first import all
data in DBF, and then try to convert these to an SQLite
database in a second step? If possible, a simple concrete
example would be greatly appreciated.</p>
<p style="margin: 0px;"> </p>
</font></blockquote>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><br>
</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;">Maybe this will
help:</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;">I have a grass
vector 'bike_rides'. It's table is dbf and looks like this:</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><br>
</p>
GRASS 6.4.0 (ITM):~ > v.db.select bike_rides<br>
cat|name|number|comment|descriptio|source|url|url_name<br>
1|Amazia #2|1|||||<br>
2|Aviya|2|||||<br>
3|ein Tamid W|3|||||<br>
4|ein Yahav 6|4|||||<br>
5|EinTamid|5|||||<br>
6|EinZin road|6|||||<br>
7|Masor|7|||||<br>
8|Masor Zaaf|8|||||<br>
9|N.Hatzeva Trk|9|||||<br>
....<br>
<br>
The current db connection:<br>
GRASS 6.4.0 (ITM):~ > v.db.connect -p bike_rides<br>
Vector map <bike_rides@Israel> is connected by:<br>
layer <1> table <bike_rides> in database
</home/micha/geodata/grass/ITM/Israel/dbf/> through driver
<dbf> with key <cat><br>
<br>
I also have a CSV file with rows like:<br>
GRASS 6.4.0 (ITM):~/geodata/tmp > cat bike_rides.csv <br>
route,difficult<br>
1,hard<br>
2,easy<br>
3,easy<br>
4,medium<br>
....<br>
<br>
Next I create a new, empty sqlite database and import the CSV table:<br>
GRASS 6.4.0 (ITM):~/geodata/tmp > sqlite3 bike_rides.db<br>
SQLite version 3.6.22<br>
Enter ".help" for instructions<br>
Enter SQL statements terminated with a ";"<br>
sqlite> CREATE TABLE difficulty (route_id integer, difficult
varchar(16));<br>
sqlite> .separator ","<br>
sqlite> .import bike_rides.csv difficulty<br>
sqlite> select * from difficulty limit 5;<br>
1,hard<br>
2,easy<br>
3,easy<br>
4,medium<br>
5,hard<br>
sqlite> .quit<br>
<br>
Now I change the default database connection for this mapset to
sqlite (This will affect all future vectors in the mapset so you'll
probably what to think about where to place the sqlite db, etc.)<br>
GRASS 6.4.0 (ITM):~/geodata/tmp > db.connect driv=sqlite
database=bike_rides.db <br>
<br>
and now I can copy the existing bike_rides vector to a new one,
which will have its attrib table in the sqlite database.<br>
<br>
GRASS 6.4.0 (ITM):~/geodata/tmp > g.copy
vect=bike_rides,bike_rides_sqlite<br>
Copy vector <bike_rides@Israel> to current mapset as
<bike_rides_sqlite><br>
<br>
Check the database connection...<br>
GRASS 6.4.0 (ITM):~/geodata/tmp > v.db.connect -p
bike_rides_sqlite<br>
Vector map <bike_rides_sqlite@Israel> is connected by:<br>
layer <1> table <bike_rides_sqlite> in database
<bike_rides.db> through driver <sqlite> with key
<cat><br>
<br>
GRASS 6.4.0 (ITM):~/geodata/tmp > v.db.select bike_rides_sqlite<br>
cat|name|number|comment|descriptio|source|url|url_name<br>
1|Amazia #2|1|||||<br>
2|Aviya|2|||||<br>
3|ein Tamid W|3|||||<br>
4|ein Yahav 6|4|||||<br>
5|EinTamid|5|||||<br>
.....<br>
<br>
Now I'm ready for the join:<br>
GRASS 6.4.0 (ITM):~/geodata/tmp > v.db.join bike_rides_sqlite
column=cat otable=difficulty ocolumn=route_id<br>
GRASS 6.4.0 (ITM):~/geodata/tmp > v.db.select bike_rides_sqlite<br>
cat|name|number|comment|descriptio|source|url|url_name|route_id|difficult<br>
1|Amazia #2|1||||||1|hard<br>
2|Aviya|2||||||2|easy<br>
3|ein Tamid W|3||||||3|easy<br>
4|ein Yahav 6|4||||||4|medium<br>
5|EinTamid|5||||||5|hard<br>
6|EinZin road|6||||||6|medium<br>
....<br>
<br>
and there you are.<br>
HTH,<br>
Micha<br>
<br>
<br>
<blockquote
cite="mid:OF59DC5BB8.AD325784-ON85257885.0018A2AF-85257885.0018A2B1@worldbank.org"
type="cite"><font face="Default Sans
Serif,Verdana,Arial,Helvetica,sans-serif" size="2">
<p style="margin: 0px;">Many thanks in advance,</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">Roy</p>
</font><br>
This mail was received via Mail-SeCure System.<br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
grass-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/grass-user">http://lists.osgeo.org/mailman/listinfo/grass-user</a>
This mail was received via Mail-SeCure System.
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Micha Silver
Arava Development Co. +972-52-3665918
<a class="moz-txt-link-freetext" href="http://www.surfaces.co.il">http://www.surfaces.co.il</a>
</pre>
</body>
</html>