[GRASS5] GRASS5.1: shapefile import problems

Hello,

I'm trying to use / import a shapefile into 5.1.

When I use v.format, The map seems perfect and d.what.vect displays the
correrct information. However, I seem to be limited to the dbf file as
database since when I use v.db.connect to try to connect the file to a
PostgreSQL database I'm told:

WARNING: Shapefile format cannot be updated.
WARNING: Shapefile format cannot be updated.
ERROR: Cannot open old vector cp@mlennert on level 0

When I use v.in.ogr + v.clean (tool=rmdupl,bpol) the file gets imported
incorrectly, areas not being recognized as area and attributes being
linked to the centroids, but not to the areas. I can link this map to the
database, but that doesn't help me with wrong topology.

As info here's v.build output on the v.format shapefile:

v.build cp
WARNING: Topology for shapefile areas is not fully supported.
Registering areas: Topology was built.
Number of nodes : 2511
Number of primitives: 2538
Number of points : 0
Number of lines : 0
Number of boundaries: 1293
Number of centroids : 1245
Number of faces : 0
Number of kernels : 0
Number of areas : 1245
Number of isles : 46
Map is 3D : 0

And here v.build output on the v.in.ogr/v.clean tool=rmdupl,bpol file:

v.build cp_clean
Registering lines:
10696 primitives registered
Building areas: 100%
77 areas built
46 isles built
Attaching islands: 100%
Attaching centroids: 100%
Topology was built.
Number of nodes : 4920
Number of primitives: 10696
Number of points : 0
Number of lines : 0
Number of boundaries: 9451
Number of centroids : 1245
Number of faces : 0
Number of kernels : 0
Number of areas : 77
Number of isles : 46
Map is 3D : 0

The first one seems correct (I haven't verified for all areas), but the
second is completely wrong.

So, my questions are:

1) can I link a shapefile imported with v.format to a database table ?
2) is there a way I can ensure a more clean import with v.in.ogr
3) knowing that the shape format is very bad, and having access to
ArcView, could I export the file to another format and import it into 5.1
?

Moritz

On Monday 02 June 2003 23:36, Moritz Lennert wrote:

Hello,

I'm trying to use / import a shapefile into 5.1.

When I use v.format, The map seems perfect and d.what.vect displays the
correrct information. However, I seem to be limited to the dbf file as
database since when I use v.db.connect to try to connect the file to a
PostgreSQL database I'm told:

WARNING: Shapefile format cannot be updated.
WARNING: Shapefile format cannot be updated.
ERROR: Cannot open old vector cp@mlennert on level 0

When I use v.in.ogr + v.clean (tool=rmdupl,bpol) the file gets imported
incorrectly, areas not being recognized as area and attributes being
linked to the centroids, but not to the areas. I can link this map to the
database, but that doesn't help me with wrong topology.

As info here's v.build output on the v.format shapefile:

v.build cp
WARNING: Topology for shapefile areas is not fully supported.
Registering areas: Topology was built.
Number of nodes : 2511
Number of primitives: 2538
Number of points : 0
Number of lines : 0
Number of boundaries: 1293
Number of centroids : 1245
Number of faces : 0
Number of kernels : 0
Number of areas : 1245
Number of isles : 46
Map is 3D : 0

And here v.build output on the v.in.ogr/v.clean tool=rmdupl,bpol file:

v.build cp_clean
Registering lines:
10696 primitives registered
Building areas: 100%
77 areas built
46 isles built
Attaching islands: 100%
Attaching centroids: 100%
Topology was built.
Number of nodes : 4920
Number of primitives: 10696
Number of points : 0
Number of lines : 0
Number of boundaries: 9451
Number of centroids : 1245
Number of faces : 0
Number of kernels : 0
Number of areas : 77
Number of isles : 46
Map is 3D : 0

The first one seems correct (I haven't verified for all areas), but the
second is completely wrong.

So, my questions are:

1) can I link a shapefile imported with v.format to a database table ?

No. Shapefile is linked by default to its dbf table.

I think that to say "imported" is maybe a bit confusing, as it is not imported.
Vector created by v.format is something like link.

First version of shapefile support was using one column from dbf (defined in frmt file)
as category values, and user could link this vector to any table (including
original dbf). Problems were that:
1) dbf part of shapefile may be without unique id column
2) it was very difficult, to define this connection, for usual users
   (Yes, you have a shapefile so why do you want to link it to something else! :slight_smile:

2) is there a way I can ensure a more clean import with v.in.ogr

I would suggest tool=bpol,rmdupl, which means first break polygons
on intersections (boundary points shared by 3 and more areas
(or 2 areas + nothing)) and then remove duplicate boundaries.
tool=rmdupl,bpol must fail on shapefile, it is OK, because duplicate boundaries
were left in vector.

tool=bpol,rmdupl can work perfectly only on clean shapefile
(generated from coverage for example), if you have overlapping areas
in shapefile, you can try tool=bpol,break,rmdupl , but result
may never be perfect (in principle).

3) knowing that the shape format is very bad, and having access to
ArcView, could I export the file to another format and import it into 5.1

I don't think that shapefile is bad, problem is that it is so different
and allowes overlapping areas. For areas is better e00, but m.in.e00
is not yet in 5.1. If you can get e00 for your file (impossible
from ArcView, I thing), you can import to 5.0, convert to 5.1 and
link to dbf.

Radim