[GRASSLIST:8059] Re: GRASS - PGSQL - PostGIS

Stephan Holl holl at gdf-hannover.de
Thu Aug 25 06:41:46 EDT 2005


Hello Martin, 

On Thu, 25 Aug 2005 12:18:10 +0200 Martin Wegmann
<wegmann at biozentrum.uni-wuerzburg.de> wrote:

> Hello, 
> 
> since a few days I am back on the GRASS-Postgresql issue, this time
> using GRASS 6, Postgis, Postgresql 7.4 (deb repository), however I am
> stumbling over a few problems:
> 
> so far I did: 
> 
> install GRASS
> install Postgresql 7.4.7
> > createuser
> > createdb grass_pg
> 
> install PostGIS (deb unstable)
> > createlang plpgsql grass_pg   

same here, works flawlessly...

> 
> inside GRASS
> >db.login driver=pg database=grass_pg
> > db.connect driver=pg database=grass_pg 

OK,  correct. Now import our tables to postgres.
g.copy vect=soils,soils_pg

Be aware that now only your attribute-data is stored inside postgres.
PostGIS does not come into play here. geometry data is in native
GRASS6-vector-format.

to load your GRASS-vectors to postgis, you could use v.out.ogr to
import to PostGIS both geometry and attributes:

v.out.ogr input=polygons type=area dsn="PG:host=localhost
dbname=postgis user=postgres" olayer=soils format=PostgreSQL

To use the exported map in GRASS relink it to your grassdata using the
command v.external.

> >v.db.connect map=soils driver=pg database=grass_pg table=test_tb
> >key=cat 
> layer=1 -o 
> >GRASS_INFO_WARNING(6534,1): Table <test_tb> does not exist in
> >database 
> <grass_pg>
> >GRASS_INFO_WARNING(6534,2): The table <test_tb> is now part of
> >vector map 
> <soils2> and may be deleted or overwritten by GRASS modules.

This assumes that the table test_tb is available in your db grass_pg.

> 
> >v.to.db map=soils2 type=point,line,boundary,centroid layer=1
> >qlayer=1 
> option=cat units=meters
> DBMI-Postgres driver error:
> Cannot select:
> SELECT cat FROM test_tb
> ERROR:  relation "test_tb" does not exist
> Updating database ... Segmentation fault
> 
> which point did I miss? 
> 
> However I would love to have a tutorial how to use GRASS in
> conjunction with Postgresql which tells me which software I do need
> and how I initialise this cross-package functionality. I haven't
> found a link to a tutorial, in case I missed it, I would be glad if
> you can send a link. 

Actually I do not have a link at hand, but perhaps we should set up a
wiki-entry for this kind of problem?
Volunteers?

Best
	Stephan

-- 
GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office      -     Mengendamm 16d      -     D-30177 Hannover
Internet: www.gdf-hannover.de      -      Email: holl at gdf-hannover.de
Phone : ++49-(0)511.39088507       -        Fax: ++49-(0)511.39088508




More information about the grass-user mailing list