[GRASS-user] v.out.ogr: Convert Attribute Database?

   Trying to convert the attribute database of a vector (points) table from
dbf to postgres, and I'm missing a critical step.

   Asked and answered:

GRASS 6.5.svn (Washington-Kinross):~/grassdata > v.db.connect
map=surface_h2o -p
Vector map <surface_h2o@buckhorn> is connected by:
layer <1> table <suface_water_sites> in database
</home/rshepard/grassdata/Washington-Kinross/buckhorn/dbf/> through driver
<dbf> with key <cat>

   Used v.out.ogr to export from dbf to a postgres table emulating the
example on the manual page:

   The example's syntax is:

Export to PostgreSQL/PostGIS
Export areas from GRASS vector map directly to PostGIS:

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

so I try,

GRASS 6.5.svn (Washington-Kinross):~/grassdata > v.out.ogr in=surface_h2o
type=point dsn="PG:dbname=buckhornmine"
Exporting 13 geometries...
  100%
v.out.ogr complete. 13 features written to <surface_h2o> (ESRI_Shapefile).

and end up with a directory called PG\:dbname\=buckhornmine/ containing the
shapefile.

   What command line do I use to transfer the attributes from the native dbf
to a postgres table in the defined database?

Rich

Used v.out.ogr to export from dbf to a postgres table

v.out.ogr - Converts GRASS vector map to one of the supported OGR vector
formats.

v.out.ogr export the entire vector map (geometry and attribute) not only the
attribute table

from the manual:
http://grass.osgeo.org/grass64/manuals/html64_user/v.out.ogr.html

Export to PostgreSQL/PostGIS
Export areas from GRASS vector map directly to PostGIS:

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

v.out.ogr in=surface_h2o
type=point dsn="PG:dbname=buckhornmine"

missing format definition?

default format is shape-file

what I would do (a very lazy way):

- create a new mapset
- using db.connect (Prints/sets general DB connection for current mapset and
exits.) to define postgres as the mapset database backend
- g.copy surface_h2o to the new mapset and the attribute table should be
automagically in the postgres

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/v-out-ogr-Convert-Attribute-Database-tp4645995p4646386.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On Thu, 22 Mar 2012, Helmut Kudrnovsky wrote:

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

missing format definition?

Helmut,

   Er, looks like I did forget the format definition.

what I would do (a very lazy way):

- create a new mapset
- using db.connect (Prints/sets general DB connection for current mapset and
exits.) to define postgres as the mapset database backend
- g.copy surface_h2o to the new mapset and the attribute table should be
automagically in the postgres

   I'll give this a try. I can then delete the original map and copy the new
one back to the project mapset.

   Will let everyone know how this works.

Thanks,

Rich

On Thu, 22 Mar 2012, Rich Shepard wrote:

Er, looks like I did forget the format definition.

Will let everyone know how this works.

   Sigh. Adding the format=PostgreSQL did the trick. Guess I needed more
caffine before lunch so as not to miss a critical option.

Again, many thanks,

Rich