Hello Martin,
On Thu, 25 Aug 2005 14:28:32 +0200 Martin Wegmann
<wegmann@biozentrum.uni-wuerzburg.de> wrote:
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?
No, this copies the dataset and adds the addtribute-data into Postgres.
> 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
>\d
shows up with the tables and it seems to be correct.
As I said, this has fed both geometr and attributes into postGIS. you
cannot digitize on this map any more (you "exported" the map into
postgis).
thanks!
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
This results in a dataset with GRASS-geometries and postgres-attributes.
> g.copy vect=test_dist_1000m,test_dist_1000m_pg
not neccessary, because the db-setting for your location were set to
postgres before, so every dataset created afterwards attributes are
stored inside postgres.
Tools like pgadmin3 [1] can help browsing postgres.
>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?"
As you are working with attribute-data, your last step (v.out.ogr) was
not neccessary, because the attributeinformation of test_dist_1000m are
already in postgres (table test_dist_1000m).
> 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.
I could certainly help including information about this topic!
Best
Stephan
[1] http://www.pgadmin.org/
--
GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508