[GRASSweb-list]markus: web/grass51/tutorial attrib_storage.html,1.5,1.6 examples.html,1.4,1.5 geom_storage.html,1.3,1.4
grass at intevation.de
grass at intevation.de
Tue Jan 21 12:39:43 EST 2003
Author: markus
Update of /grassrepository/web/grass51/tutorial
In directory doto:/tmp/cvs-serv11964
Modified Files:
attrib_storage.html examples.html geom_storage.html
Log Message:
PostGIS/PostGRASS support added, some style cleanup
Index: attrib_storage.html
===================================================================
RCS file: /grassrepository/web/grass51/tutorial/attrib_storage.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- attrib_storage.html 15 Jan 2003 18:01:36 -0000 1.5
+++ attrib_storage.html 21 Jan 2003 17:39:41 -0000 1.6
@@ -35,7 +35,32 @@
send us further examples and/or code bugfixes/enhancements.</i>
<P>
-<h2>Introduction</h2>
+
+<hr>
+<a name="toc"></a>
+<ol>
+<li><a href="#intro">Introduction</a>
+<li><a href="#DBF">Attributes stored in DBF table</a>
+<li><a href="#ODBC">Attributes stored in external database (PostgreSQL)
+ connected through ODBC</a>
+<li><a href="#PostgreSQL">Attributes stored in external database (PostgreSQL)
+ directly connected</a>
+<li><a href="#mySQL">Attributes stored in external database (mySQL)
+ directly connected</a>
+<li><a href="#StarOffice">Changing table column types with StarOffice</a>
+<li><a href="#OpenOffice">Changing table column types with OpenOffice</a>
+</ol>
+
+To get debug information, set variable (set to 0 for debug silence) to 1..5:<div class="code"><pre>
+export GRASS_DEBUG_LEVEL=5
+</div></pre>
+
+<p><table width="100%" cellpadding="3" border="0">
+<tr><td align="left" bgcolor="#B0F0B0"><font color="#00000"><big><b>
+<a name="intro"></a>
+Introduction
+<DIV ALIGN=right><a href="#toc">[UP]</a></DIV>
+</b></big></font></td></tr></table>
The attribute management was completely changed in GRASS 5.1 to achieve
multi-attribute capabilities managed within external databases. The former
dig_cats/ files are not used any more and all vector attributes are stored
@@ -91,37 +116,17 @@
database and driver names. Note that $MAPSET is not current mapset but
mapset of the map the rule is defined for.
-<hr>
-<ol>
-<li><a href="#DBF">Attributes stored in DBF table</a>
-<li><a href="#ODBC">Attributes stored in external database (PostgreSQL)
- connected through ODBC</a>
-<li><a href="#PostgreSQL">Attributes stored in external database (PostgreSQL)
- directly connected</a>
-<li><a href="#mySQL">Attributes stored in external database (mySQL)
- directly connected</a>
-<li><a href="#StarOffice">Changing table column types with StarOffice</a>
-<li><a href="#OpenOffice">Changing table column types with OpenOffice</a>
-</ol>
-
-To get debug information, set variable (set to 0 for debug silence) to 1..5:<div class="code"><pre>
-export GRASS_DEBUG_LEVEL=5
-</div></pre>
-
<p><table width="100%" cellpadding="3" border="0">
<tr><td align="left" bgcolor="#B0F0B0"><font color="#00000"><big><b>
<a name="DBF"></a>
Attributes stored in DBF file
+<DIV ALIGN=right><a href="#toc">[UP]</a></DIV>
</b></big></font></td></tr></table>
-Example: Connection of SHAPE file with attributes in DBF file.<p>
+Example: Connection of SHAPE file with attributes in DBF file which was
+registered with 'v.shape.register' (see <a href=geom_storage.html#SHAPE>here</a>).
-An entry in the GRASS 5.1 'DB' file such as:
-<div class="code"><pre>
-markveggy.shp 1 markveggy VEGCNP_ID /ssi0/ssi/neteler/grassdata/botswanaLL/shp dbf
-</div></pre>
-is required.
<p>
You can check the connection of a vector map to a table:
@@ -145,6 +150,7 @@
<a name="ODBC"></a>
Attributes stored in external database (PostgreSQL) connected
through ODBC
+<DIV ALIGN=right><a href="#toc">[UP]</a></DIV>
</b></big></font></td></tr></table>
Possible communication between GRASS 5.1 and PostgreSQL database for
@@ -260,28 +266,14 @@
createdb -h rastrel grass51test
</div></pre>
-<li>Now store the table into PostgreSQL (you may use pg.in.dbf from 5.0 or other
-tools).
-
-<li>
-Now run the 'db.connect' command:
+<li>Now store the table 'markveggy.dbf' into PostgreSQL:
<div class="code"><pre>
db.connect driver=odbc database=grass51test
+db.copy from_driver=dbf from_database=./ from_table=markveggy \
+ to_driver=pg to_database="host=pgserver,dbname=grass51test" \
+ to_table=markveggy
</div></pre>
-<li>Next we dump the DBF file into PostgreSQL (NOTE: unless we don't have a
- 'db.copy' command, we may 'pg.in.dbf' from GRASS 5.0 or
- the external 'pg2xbase' software):
-<div class="code"><pre>
-#go to directory, where registered SHAPE/DBF files are:
-cd `g.gisenv GISDBASE`
-cd `g.gisenv LOCATION_NAME`
-cd shp
-
-pg.in.dbf in=markveggy.dbf dumpmode=normal
-</div></pre>
-
-
<li> Next add an entry in the GRASS 5.1 'DB' file:
<div class="code"><pre>
# map field table ID database DBMIdriver
@@ -317,6 +309,7 @@
<a name="PostgreSQL"></a>
Attributes stored in PostgreSQL database table
directly connected
+<DIV ALIGN=right><a href="#toc">[UP]</a></DIV>
</b></big></font></td></tr></table>
Example: Connection of SHAPE file with attributes in PostgreSQL database table
@@ -329,8 +322,13 @@
createdb -h rastrel grass51test
</div></pre>
-Now store the table into PostgreSQL (you may use pg.in.dbf from 5.0 or other
-tools).
+Now store the table 'markveggy.dbf' into PostgreSQL:
+<div class="code"><pre>
+db.connect driver=odbc database=grass51test
+db.copy from_driver=dbf from_database=./ from_table=markveggy \
+ to_driver=pg to_database="host=pgserver,dbname=grass51test,user=neteler" \
+ to_table=markveggy
+</div></pre>
<p>
Let's assume that PostgreSQL runs on machine 'pgserver'.
Add entry in the GRASS 5.1 'DB' file in the mapset directory:
@@ -371,6 +369,7 @@
<tr><td align="left" bgcolor="#B0F0B0"><font color="#00000"><big><b>
<a name="mySQL"></a>
Attributes stored in mySQL database table
+<DIV ALIGN=right><a href="#toc">[UP]</a></DIV>
</b></big></font></td></tr></table>
Example: Connection of SHAPE file with attributes in mySQL database table
@@ -382,6 +381,7 @@
<tr><td align="left" bgcolor="#B0F0B0"><font color="#00000"><big><b>
<a name="StarOffice"></a>
Changing table column types with StarOffice
+<DIV ALIGN=right><a href="#toc">[UP]</a></DIV>
</b></big></font></td></tr></table>
Sometimes the ID field in a database table (e.g. .dbf) is of a wrong type.
@@ -415,6 +415,7 @@
<p><table width="100%" cellpadding="3" border="0"> <tr><td align="left"
bgcolor="#B0F0B0"><font color="#00000"><big><b> <a name="OpenOffice"></a>
Changing table column types with OpenOffice
+<DIV ALIGN=right><a href="#toc">[UP]</a></DIV>
</b></big></font></td></tr></table>
Sometimes the ID field in a database table (e.g. .dbf) is of a wrong type.
@@ -444,7 +445,8 @@
Select the column and change the type to "Number" (alias Integer). Save the
table. Now GRASS 5.1 can use the ID column as it is of Integer type.
<br>
-PROBLEM: In OpenOffice 1.0.1 Number/Integer does not exist!!
+PROBLEM: In OpenOffice 1.0.1 Number/Integer does not exist!! So you better
+go with StarOffice.
<hr>
<b>Further Links:</b>
Index: examples.html
===================================================================
RCS file: /grassrepository/web/grass51/tutorial/examples.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- examples.html 17 Jan 2003 17:37:45 -0000 1.4
+++ examples.html 21 Jan 2003 17:39:41 -0000 1.5
@@ -360,7 +360,7 @@
<div class="code"><pre>
db.copy from_driver=dbf from_database=./ from_table=census1990wet \
- to_driver=pg to_database=host=pgserver,dbname=grass51test \
+ to_driver=pg to_database="host=pgserver,dbname=grass51test" \
to_table=census1990wetB
</div></pre>
Index: geom_storage.html
===================================================================
RCS file: /grassrepository/web/grass51/tutorial/geom_storage.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- geom_storage.html 9 Jan 2003 17:58:05 -0000 1.3
+++ geom_storage.html 21 Jan 2003 17:39:41 -0000 1.4
@@ -35,7 +35,27 @@
send us further examples and/or code bugfixes/enhancements.</i>
<P>
-<h2>Introduction</h2>
+
+<hr>
+<a name="toc"></a>
+<ol>
+<li><a href="#native">Geometry stored in native format</a>
+<li><a href="#SHAPE">Geometry stored in SHAPE file: Registration of a map in
+SHAPE format</a>
+<li><a href="#PostGRASS">Geometry stored in external database (PostGRASS)
+using PostGIS</a>
+</ol>
+
+To get debug information, set variable (set to 0 for debug silence) to 1..5:<div class="code"><pre>
+export GRASS_DEBUG_LEVEL=5
+</div></pre>
+
+<p><table width="100%" cellpadding="3" border="0">
+<tr><td align="left" bgcolor="#B0F0B0"><font color="#00000"><big><b>
+<a name="native"></a>
+Introduction
+<DIV ALIGN=right><a href="#toc">[UP]</a></DIV>
+</b></big></font></td></tr></table>
In GIS the vector data model is used for geographic phenomena which may be
represented by geometric entities (primitives) like points, lines, and
areas. In GRASS 5.1 the vector data model includes the description of
@@ -69,24 +89,11 @@
See some vector API details <a href="http://freegis.org/cgi-bin/viewcvs.cgi/~checkout~/grass51/doc/vector/vector.html">here</a>.
-<hr>
-<ol>
-<li><a href="#native">Geometry stored in native format</a>
-<li><a href="#SHAPE">Geometry stored in SHAPE file: Registration of a map in
-SHAPE format</a>
-<li><a href="#PostGRASS">Geometry stored in external database (PostGRASS)
-using PostGIS</a>
-</ol>
-
-To get debug information, set variable (set to 0 for debug silence) to 1..5:<div class="code"><pre>
-export GRASS_DEBUG_LEVEL=5
-</div></pre>
-
-
<p><table width="100%" cellpadding="3" border="0">
<tr><td align="left" bgcolor="#B0F0B0"><font color="#00000"><big><b>
<a name="native"></a>
Geometry stored in native format
+<DIV ALIGN=right><a href="#toc">[UP]</a></DIV>
</b></big></font></td></tr></table>
Per default the vector geometry is stored in the GRASS 5.1 location
@@ -99,25 +106,17 @@
<p><table width="100%" cellpadding="3" border="0">
<tr><td align="left" bgcolor="#B0F0B0"><font color="#00000"><big><b>
-<a name="ODBC"></a>
-Geometry stored in SHAPE file: Registration of a map in SHAPE format
+<a name="SHAPE"></a>
+Geometry stored in SHAPE file: Registering a map in SHAPE format
+<DIV ALIGN=right><a href="#toc">[UP]</a></DIV>
</b></big></font></td></tr></table>
Direct SHAPE file support is implemented, i.e. maps in SHAPE format can be
-used directly in GRASS 5.1 without importing them.
+used directly in GRASS 5.1 without importing them. But you have to register
+the SHAPE file, it may be useful to copy them into the LOCATION:
<div class="code"><pre>
-#register SHAPE files (this will copy them into the LOCATION):
-
v.shape.register markveggy.shp
- markveggy.shp is registered now.
- The SHAPE files (.shp, shx and .dbf) were copied to:
- /ssi0/ssi/neteler/grassdata/botswanaLL/shp
- Consider to run v.build:
- v.build markveggy.shp
-
-#build pseudo-topology for SHAPE
- v.build markveggy.shp
#get info about vector map:
v.info markveggy.shp
@@ -127,7 +126,7 @@
d.vect markveggy.shp
</div></pre>
-DBF table do not have to be registered in the DB file.
+For SHAPE format, DBF table do not have to be registered in the DB file.
Read also <a href="attrib_storage.html#DBF">Attributes stored in DBF table</a>.
<div class="code"><pre>
@@ -141,17 +140,83 @@
<tr><td align="left" bgcolor="#B0F0B0"><font color="#00000"><big><b>
<a name="PostGRASS"></a>
Geometry stored in PostGRASS database table using PostGIS
+<DIV ALIGN=right><a href="#toc">[UP]</a></DIV>
</b></big></font></td></tr></table>
-Using PostGRASS which stores the vector geometry in a PostgreSQL/PostGIS
-database, multiple user write access to vector geometry becomes possible.
-
+Current PostGRASS limitations: It is not possible use PostGIS data imported
+by ogr2ogr in GRASS (OGR support is planned but not yet present).
+Data must be first imported into GRASS, then written to PostGIS.
+<br>
+<i>Future: Using PostGRASS which stores the vector geometry in a
+PostgreSQL/PostGIS database, multiple user write access to vector geometry
+will become possible. Then also updating of vector geometry stored in
+PostGRASS with v.digit will be possible.</i>
<P>
-TODO.
+
+In this example we want to put the vector map 'census1990wet.shp' (a SHAPE
+file registed into GRASS) into database 'botswanaUTM34' on server 'pgserver'
+as user 'postgres'. First we create a PostGIS database (the example needs
+the file postgis.sql in the current directory):
+
+<div class="code"><pre>
+postgisdb -c botswanaUTM34 -h pgserver.itc.it -U postgres -G ./
+</div></pre>
+
+Next we have to create a 'frmt' file which defines the PostGRASS connection
+and a 'head' file which defines the basic vector names:
+<div class="code"><pre>
+cd $HOME/grassdata/botswanaUTM34/PERMANENT/vector
+mkdir pgmap
+cd pgmap
+</div></pre>
+
+Here generate the ASCII file 'frmt':
+<div class="code"><pre>
+FORMAT:postgis
+HOST:pgserver.itc.it
+DATABASE:botswanaUTM34
+USER:postgres
+GEOM_TABLE:pgmapg
+CAT_TABLE:pgmapc
+</div></pre>
+
+Next we need a 'head' file (you may re-use another 'head' file from another
+vector map):
+<div class="code"><pre>
+ORGANIZATION: GRASS Development Team
+DIGIT DATE: /9/Jan
+DIGIT NAME: neteler
+MAP NAME: pgmap
+MAP DATE: 2002
+MAP SCALE: 50000
+OTHER INFO: -
+ZONE: 0
+MAP THRESH: 0.500000
+</div></pre>
+
+Finally we import the map to PostGRASS:
+
+<div class="code"><pre>
+v.out.ascii input=census1990wet.shp out=pgmap
+v.in.ascii input=pgmap out=pgmap
+</div></pre>
+
+For the attributes storage in PostgreSQL, please <a
+href="attrib_storage.html#PostgreSQL">read on here</a> ('db.copy' will
+help).
+
<P>
-Hints for GRASS-PostGIS: see e.g. <a
+Further hints for GRASS/PostGRASS/PostGIS: see e.g. <a
href="http://grass.itc.it/pipermail/grassuser/2002-November/015822.html">this
thread</a>.
+
+
+<hr>
+<b>Further Links:</b>
+
+<ul>
+<li><a href=http://postgis.refractions.net/docs/>PostGIS manual</a><br>
+</ul>
<!-- FOOTER -->
<p>
More information about the grass-web
mailing list