[GRASS-user] db.out.ogr: Syntax Correction

Micha Silver micha at arava.co.il
Sat Mar 12 11:58:10 EST 2011


On 03/11/2011 09:57 PM, Rich Shepard wrote:

>   I want to migrate attribute data from the internal dbf to an external
> postgres table and thought that db.out.ogr was the proper module. 
> However,
> following the example on the 6.5 manual page does not work for me.
>
>   Manually breaking lines that were continuous in the terminal, he 
> example shows:
>
> db.out.ogr points_tab dsn="PG:host=localhost dbname=postgres 
> user=neteler" \
>  format=PostgreSQL
> echo "SELECT * FROM points_tab" | psql postgres
>
>   What I tried:
>
> GRASS 6.5.svn (Nevada-aea):~/grassdata > db.out.ogr at_risk_species \
>   dsn="PG:host=localhost dbname=nevada" format=PostgreSQL \
>   echo "SELECT * FROM at_risk_species" | psql nevada
> Sorry <echo> is not a valid option
> Sorry <SELECT * FROM at_risk_species> is not a valid option
> Error in usage. Call b.out.ogr --help for assistance.
>
>   Then I tried just the first line of the command:

The second line is just meant as a check that the attribs are indeed 
uploaded to the PostgreSQL database...

>
> GRASS 6.5.svn (Nevada-aea):~/grassdata > db.out.ogr at_risk_species
> dsn="PG:host=localhost dbname=nevada" format=PostgreSQL
> WARNING: The map contains islands. To preserve them in the output map, 
> use
>          the -c flag
> WARNING: 13 boundary(ies) found, but not requested to be exported. Verify
>          'type' parameter.
> WARNING: 13 centroid(s) found, but not requested to be exported. Verify
>          'type' parameter.
> WARNING: 13 areas found, but not requested to be exported. Verify 'type'
>          parameter.
> WARNING: No points found, but requested to be exported. Will skip this
>          geometry type.
> WARNING: Nothing to export
> Exported table <at_risk_species>
>
>   Please tell me what I've missed here.

What do these show:
v.info -t at_risk_species
v.info -c at_risk_species

The script above is a wrapper around v.out.ogr. If I understand 
correctly, you want to have a new GRASS point vector with the data table 
held in Postgres? So maybe v.out.ogr is the easier approach.
Furthermore, if you're going to change the whole project over to 
database stored attribs, then the best method is to set the new database 
connection for your mapset (db.connect + db.login) then just run db.copy 
on all your vectors. All the new "copies" will have their data tables in 
the (now default) database.

Something like:
$ for v in `g.mlist vect sep=space`; do g.rename vect=$v,$v_old; done
$ for v in `g.mlist vect sep=space pat="*_old"`; do g.copy 
vect=$v,`basename $v _old`; done
# This should leave you with a set of dbf based vectors named like: 
a_vector_old
# And a second set, postgres based, named like "a_vector"

# Now test that the new tables exist:
psql -c 'SELECT * FROM <a vector>'  -d <your_postgres_db> -U 
<your_db_username>
# If everything looks OK, remove the old (dbf based) vectors
$ g.mremove vect="*_old"

Cheers,
-- 
Micha

>
> Rich
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
> This mail was received via Mail-SeCure System.
>
>


-- 
Micha Silver
Arava Development Co. +972-52-3665918
http://www.surfaces.co.il




More information about the grass-user mailing list