[GRASS-de] probleme und fehler von und mit grass und postgres

Ingo Wichmann wichmann at uni-wuppertal.de
Di Aug 6 12:54:21 CEST 2002


(Bitte entschuldigt, daß ich die Mail auf englisch geschrieben habe. Als 
ich sie verfasst habe saß ich auf einer Wiese an einem See, weit weg von 
meinen restlichen emails und dachte die grass liste die ich abonniert 
habe sei englisch.)

I tried to import some shape-file data along with its attributes to 
There where several problems i couldn't solve:
- d.what.vect crashes when i query some roads
- pg.in.dbf stops with error because of a duplicate attributename
- v.in.shape.pg crashes

After changing the name of the duplicate attribute (see below for more) 
with vi in the dbf-file pg.in.dbf worked.v.in.shape.pg still does not work.
Is there an other way to import a shape-file into a postgresql-database, 
maybe without grass? I've found Perl-Bindings for shapelib. Does anybody 
use this?

These are the steps i did:

First, i tried to simply import them to the grass-database, with one 
attribute only:

# v.in.shape -o in=/home/wichmann/dpa/shape_files_is/strasse.shp 
File `strasse.shp' is of Type Line (Arc) with 2928 entries.
Map `strasse' imported, apparently without problems.

# d.erase
# v.support -r map=strasse


Selected information from vector header
  Map Name:      strasse
  Source Date:
  Orig. Scale:   2400
  Snapping threshold    0.00
Snapp No snapping will be done
     Reading Vector file 100%
     Building areas 100%
     Building islands (no islands present)
     Attaching labels
  WARNING: line 1032 label: 526 matched another label: 1032.

..  (about 30 similar warnings)

  Number of lines:   2940
  Number of nodes:   2500
  Number of areas:   0
  Number of isles:   0
  Number of atts :   2940
  Number of unattached atts :   0
  Snapped lines  :   0

# d.vect map=strasse color=blue
  (roads are displayed)
# d.what.vect map=strasse
3408653.10833333(E) 5686922.16666667(N)
strasse in wichmann  Line - Category 2408 Eileringser Straße

3403699.025(E) 5695267.89166667(N)

Then i tried to import everything into postgres:

Similar to the tutorial in grass5.0.0pre5/src.garden/grass.postgresql i 
started with

# g.select.pg host=localhost database=strasse
# pg.in.dbf in=/home/wichmann/dpa/shape_files_is/strasse.dbf
Executing create table strasse (ID int8,LäNGENBERE float4,ID_KEY 
float4,MAßNAHME text,MAßNAHMENJ int4,BLK text,OD text)
FIXME: Postgres Says:
ERROR:  CREATE TABLE: attribute "abschnittn" duplicated

Please make sure that created table name is not used by another table.

# v.in.shape.pg in=/home/wichmann/dpa/shape_files_is/strasse.shp 
attribute=ID label=STRASSENNA

At last, i changed the name of the doubled attribute and tried again:
# pg.in.dbf in=/home/wichmann/dpa/shape_files_is/strasse.dbf dumpmode=normal
(works fine)

# dropdb strasse
# createdb strasse
# v.in.shape.pg in=/home/wichmann/dpa/shape_files_is/strasse.shp 

Not assigning category labels

Selected information from vector header
  Map Name:      strasse
  Source Date:
  Orig. Scale:   2400
  No snapping will be done

     Reading Vector file.
    5  11  17  23  29  35  41  47  53  59  65  71  77  83  89  95 100
Identical lines check
Compressing Data:
  Compressing NODES.^M Compressing NODES.  LINES.^M Compressing NODES. 
REAS.^M Compressing NODES.  LINES.  AREAS.  ISLES.^M Compressing NODES. 
  AREAS.  ISLES. ATTS.^MCompressing Data:   DONE.

     Building areas
    2   5   8  11  14  17  20  23  26  29  32  35  38  41  44  47  50 
53  56  59
   62  65  68  71  74  77  80  83  86  89  92  95  98 100
     Building islands
  (no islands present)
     Attaching labels
  WARNING: line 2841 label: 85 matched another label: 127.
  WARNING: line 1082 label: 20 matched another label: 552.
.. (about 25.000 similar warnings)
  Number of lines:   2895
  Number of nodes:   2300
  Number of areas:   0
  Number of isles:   0
  Number of atts :   28907
  Number of unattached atts :   41
  Snapped lines  :   0

The output looks as if it worked, but it didn't. There is nothing in the 

Here is a list of the columns in the dbf-file. Maybe it helps. I don't 
remember the command to generate it.

1: ID [int8:16]
2: LäNGENBERE [float4:16]
3: ID_KEY [int4:4]
4: KATEGORIE [int4:1]
5: ABSCHNITTN [text:14]
6: STRAßENSCH [int4:4]
7: ABSCHNITTL [float4:7]
8: ABSCHNITTN [text:16]
9: STRASSENNA [text:22]
10: SCHADENSAR [text:23]
11: AUSPRäGUNG [text:10]
12: STRSCHL [int4:4]
13: ELEMENTBRE [float4:4]
14: UMFANG_IN_ [int4:3]
15: SCHADENSFL [float4:7]
16: MAßNAHME [text:22]
17: MAßNAHMENJ [int4:4]
18: BLK [text:16]
19: OD [text:16]

Here are some errors i found in 

The command to remove the database from postgresql is
dropdb humus
instead of
destroydb humus

The parameters input and pgdump of v.in.shape.pg do not work. Instead of
you have to use
I don't know what the pgdump parameter is for nor how to replace it.