Martin Wegmann wegmann at biozentrum.uni-wuerzburg.de
Thu Aug 25 08:28:32 EDT 2005

hello Stephan, 

On Thursday 25 August 2005 12:41, Stephan Holl wrote:
> > 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

why that command? It is important for the pgsql connection or rather to have 
it in the current mapset?

> 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

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

works fine and entering pgsql

>psql grass_pg
shows up with the tables and it seems to be correct. 


Just one curious question, if I do 

>v.distance from=soils2 to=soils2 upload=dist column=dist out=test_dist_1000m 
from_type=centroid to_type=centroid -a dmax=1000
> g.copy vect=test_dist_1000m,test_dist_1000m_pg
>v.out.ogr input=test_dist_1000m_pg type=point dsn="PG:host=localhost 
dbname=grass_pg user=baliola" olayer=dist_1000m format=PostgreSQL    

and enter PGSQL
>psql grass_pg
>select * from dist_1000m_p;   

I get:

ogc_fid |                               wkb_geometry
    | cat
       1 | \001\001\000\000\000\303\365(\\\340\217"Aq=\012\367\035\277RA
       2 | \001\001\000\000\000\\\217\302\365\265\212"A\366(\\/\207\277RA
       3 | \001\001\000\000\000\303\365(\334\322\227"A333\003D\277RA

which looks for me pretty weird. How do I solely extract the distance values 
into PGSQL?
The general question would be, "how do I export single columns only?"

> To use the exported map in GRASS relink it to your grassdata using the
> command v.external.
> >
> > 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?

yeeph, I would volunteer, however I can provide the rough first steps only; 
the nifty bits and pieces are not yet in my repertoire.

cheers Martin

More information about the grass-user mailing list