[GRASSweb-list]markus: web/grass51 examples.html,1.4,1.5

grass at intevation.de grass at intevation.de
Mon Nov 4 11:54:42 EST 2002


Author: markus

Update of /grassrepository/web/grass51
In directory doto:/tmp/cvs-serv1211

Modified Files:
	examples.html 
Log Message:
more ODBC examples

Index: examples.html
===================================================================
RCS file: /grassrepository/web/grass51/examples.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- examples.html	31 Oct 2002 17:38:52 -0000	1.4
+++ examples.html	4 Nov 2002 16:54:39 -0000	1.5
@@ -44,7 +44,7 @@
 <p>
 d.m is a new display manager.
 
-<h2>Example 0: Convert 5.0 vector maps to 5.1</h2>
+<h2>Example 1: Convert 5.0 vector maps to 5.1</h2>
 You can run 5.1 (at the same time) on a 5.0 location without problems.<br>
 To convert 5.0 vector data to 5.1, run:
 <pre>
@@ -54,7 +54,15 @@
 Vector maps from 5.0 and 5.1 do not interfere (different directories),
 so you can use the  same names.
 
-<h2>Example 1: Registration of a map in SHAPE format</h2>
+<h2>Example 2: Export of 5.1 vector map to GRASS 5.0</h2>
+
+<pre>
+v.out.ascii -o newmap.clean out=newmap.clean
+</pre>
+
+Then go to 5.0 and run v.in.ascii + v.support.
+
+<h2>Example 3: Registration of a map in SHAPE format</h2>
 
 Maps in SHAPE format can be used directly in GRASS 5.1 without importing
 them.
@@ -108,7 +116,7 @@
 </pre>
 
 
-<h2>Example 3: Export data using OGR</h2>
+<h2>Example 4: Export data using OGR</h2>
 
 Export to SHAPE format (generates /tmp/testogr.shp and related files):
 <pre>
@@ -122,7 +130,7 @@
 </pre>
 
 
-<h2>Example 4: Conversion of SHAPE map to GRASS 5.1 vector map</h2>
+<h2>Example 5: Conversion of SHAPE map to GRASS 5.1 vector map</h2>
 
 #WARNING: don't try this at home. Pretty unstable yet.
 
@@ -168,13 +176,136 @@
 d.what.vect newmap
 </pre>
 
-<h2>Example 5: Export to GRASS 5.0</h2>
+<h2>Example 6: Connecting GRASS 5.1 DBMI (attributes) to PostgreSQL
+      through ODBC</h2>
 
+Possible communication between GRASS 5.1 and PostgreSQL database for
+    attribute management: <p>
+
+<table cellpadding="2" cellspacing="2" border="1" align="center">
+  <tbody>
+    <tr>
+      <td valign="top" align="center" bgcolor="#99ff99">GRASS module &lt;-&gt;&nbsp;
+DBMI &lt;-&gt; ODBCdriver</td>
+      <td valign="top" align="center" bgcolor="#99ff99">&lt;-&gt;</td>
+      <td valign="top" align="center" bgcolor="#99ff99">unixODBC</td>
+      <td valign="top" align="center" bgcolor="#99ff99">&lt;--&gt;</td>
+      <td valign="top" align="center" bgcolor="#99ff99">ODBC-to-PostgreSQL-driver
+&lt;-&gt; PostgreSQL Database</td>
+    </tr>
+    <tr>
+      <td valign="top" align="center"><i><b>GRASS<br>
+      </b></i></td>
+      <td valign="top" align="center"><i><b>&lt;-&gt;<br>
+      </b></i></td>
+      <td valign="top" align="center"><i><b>Interface<br>
+      </b></i></td>
+      <td valign="top" align="center"><i><b>&lt;-&gt;<br>
+      </b></i></td>
+      <td valign="top" align="center"><i><b>PostgreSQL<br>
+      </b></i></td>
+    </tr>
+  </tbody>
+</table>
+
+<ul>
+<li>
+Configure ODBC driver for selected database (without ODBCConfig). ODBC
+drivers are defined in /etc/odbcinst.ini. Here is example:</li>
+
+<pre>&nbsp;[PostgreSQL]
+&nbsp;Description&nbsp;&nbsp;&nbsp;&nbsp; = ODBC for PostgreSQL
+&nbsp;Driver&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = /usr/lib/libodbcpsql.so
+&nbsp;Setup&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = /usr/lib/libodbcpsqlS.so
+&nbsp;FileUsage&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 1</pre>
+
+<li> Create DSN (data source name). DSN is used as database name in db.*
+modules. Then DSN must be defined in $HOME/.odbc.ini (for this user only) or in
+/etc/odbc.ini for (for all users) [watch out for the database name which
+appears twice and the PostgreSQL protocol version]. Omit blanks at the beginning of
+lines:</li>
+
+<pre>&nbsp;[grass51test]
+&nbsp;Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = PostgreSQL
+&nbsp;Driver&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = PostgreSQL
+&nbsp;Trace&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = No
+&nbsp;TraceFile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
+
+&nbsp;Database&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = grass51test
+&nbsp;Servername&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = localhost
+&nbsp;UserName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
+&nbsp;Password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
+&nbsp;Port&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 5432
+&nbsp;Protocol&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 7.0.3
+
+&nbsp;ReadOnly&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = No
+&nbsp;RowVersioning&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = No
+&nbsp;ShowSystemTables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = No
+&nbsp;ShowOidColumn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = No
+&nbsp;FakeOidIndex&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = No
+&nbsp;ConnSettings&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =</pre>
+
+Configuration of an DSN without GUI is described on <a href="http://www.unixodbc.org/odbcinst.html">http://www.unixodbc.org/odbcinst.html</a>,
+but odbc.ini and .odbc.ini may be created by GUI ODBCConfig and you can
+easily&nbsp; view your DSN structure by DataManager. Configuration with
+GUI is described on <a href="http://www.unixodbc.org/doc/UserManual/">http://www.unixodbc.org/doc/UserManual/</a>
+<p>
+To find out about your PostgreSQL protocol, run <br>
+<tt>cat /var/lib/pgsql/data/PG_VERSION</tt><br>
+or <br>
+<tt>psql -V</tt> 
+
+<li>
+Now create the database (if not yet existing, '-h host' defines the
+        PostgreSQL server host):
 <pre>
-v.out.ascii -o newmap.clean out=newmap.clean
+createdb -h rastrel grass51test
 </pre>
 
-Then go to 5.0 and run v.in.ascii + v.support.
+<li>
+Now run the 'db.connect' command:
+<pre>
+db.connect driver=odbc database=grass51test
+</pre>
+
+<li>Next we dump the DBF file into PostgreSQL (NOTE: unless a
+            'db.copy' does not exist, we use 'pg.in.dbf' from GRASS 5.0):
+<pre>
+pg.in.dbf in=markveggy.dbf dumpmode=normal 
+</pre>
+
+<li>
+Finally a test: Here we should see the table columns (if the ODBC
+              connection works):
+<pre>
+db.columns table=markveggy
+</pre>
+</ul>
+
+<h2>Example 7: Export of SHAPE-DBF file to PostgreSQL and vector map
+      link to PostgreSQL through ODBC</h2>
+
+<pre>
+#go to directory, where registered SHAPE/DBF files are:
+cd `g.gisenv GISDBASE`
+cd `g.gisenv LOCATION_NAME`
+cd shp
+
+Now you have to use "createdb" do create database tables.
+First we create an empty table:
+createdb humus This new table we select in GRASS:
+g.select.pg database=humus To destroy a database use: "destroydb humus" (PostgreSQL 6.x) or "dropdb humus" (PostgreSQL 7.x).
+
+In this first step we import the plain attribute table only without importing geographical features.
+To import the Dbase-table into PostgreSQL enter:
+pg.in.dbf in=humus.dbf
+  Executing create table humus (AREA float4,PERIMETER float4,G2_UEB09_
+  int8,G2_UEB09_I int8,STONR int4,BOTYP text,HORIZ text,BODART text,HUMUS
+  float4,SKELETT text) You will be asked: Additionally dump to ASCII file (enter full Unix name or hit  <return> for none):
+Enter "ENTER" if you don't need an additional ASCII file in your local directory.
+
+The table is imported into PostgreSQL now.
+</pre>
 
 <!-- FOOTER -->
 <p>





More information about the grass-web mailing list