[GRASS5] GRASS5.7: trouble converting shapefile to postgis with v.convert

Radim Blazek blazek at itc.it
Fri Dec 5 05:33:04 EST 2003


On Thursday 04 December 2003 19:17, Moritz Lennert wrote:
> Hello,
>
> I have a shapefile registered in GRASS5.7:
>
> *******
> GRASS 5.7.-cvs:~ > g.list vect
> ----------------------------------------------
> vector files available in mapset mlennert:
> communes.shp
>
> ----------------------------------------------
> ************
>
> I can display and query this file without any problems.
>
> It is connected to a dbf file:
>
> *************
> GRASS 5.7.-cvs:~ > v.db.connect -p communes.shp
> Vector map <communes.shp> is connected by:
> field <1> table <communes> in database </home/mlennert/SHAPEFILES/>
> through driver <shp> with key <shp_fid>
> **************
>
> Following the tutorial, I tried to store this map in PostGIS format:
>
> *************
> GRASS 5.7.-cvs:~ > v.database driver=pg database="dbname=digit_belgium"
> GRASS 5.7.-cvs:~ > v.convert input=communes.shp output=communes
> *************
>
> but I got the error message: "ERROR: Input vector was not found."
>
> What am I doing wrong ?

v.convert converts old GRASS vector files (GRASS 4.0,5.0) to 5.1/7 format.
v.database is used to set the database for attributes.
If you want to write a vector in PostGIS format, you have first set 
the output vector format to PostGIS either in 
v.format -> output format -> PostGIS 
or by g.gisenv:
g.gisenv store=mapset set=GV_FORMAT=POSTGIS
g.gisenv store=mapset set=GV_PGIS_DATABASE=host=liptakov,dbname=cimrman,user=jara

Once you set vector format to PostGIS, all new vectors are written to the database.
Attributes are by default written to dbf files, so until you set also 
v.database driver=pg database="dbname=digit_belgium"
you get geometry in Postgres and attributes in dbf, isn't it funny?

To convert the vector you can run g.copy for example, but that is not what you want
as communes will be polygons and you have to clean such vector first.
I would recommend v.in.ogr as it does all the cleaning. See the statistics about
areas at the end.

Radim




More information about the grass-dev mailing list