[GRASS-user] Connect additional dbf file based on layer 1 attribute column

Moritz Lennert mlennert at club.worldonline.be
Mon Mar 31 11:20:38 EDT 2008


On 31/03/08 16:04, Luigi Ponti wrote:
> Dear list,
> 
> I am trying to import the European Vector Database (ESDB) version 2 to 
> GRASS -- original data is ArcInfo shapefile. Maybe most of you already 
> know about this freely downloadable database, but for those who don't: 
> http://eusoils.jrc.ec.europa.eu/Library/ESDAC/Online_Data.cfm
> 
> Well, the main ESDB shapefile layer name is called sgdbe4_0, which comes 
> in the usual .shp, .prj, .shx, and .dbf extensions. The sgdbe4_0 layer 
> gets imported OK via v.in.ogr, but most of the soil database is left out 
> of the new GRASS vector, because it is included in additional .dbf files 
> with different names, which are therefore not imported into the new 
> GRASS vector.
> 
> The sgdbe4_0.dbf table in the GRASS vector has at least one attribute 
> column in common with the other additional .dbf files that don't get 
> imported. Is it possible to connect those .dbf files to the imported 
> GRASS vector based on an attribute column (not the 'cat' column) that is 
> present both in layer 1 of the vector and in those additional (not 
> connected) .dbf files?


Several options:

1) Use a real database backend (sqlite, postgresql), import the other 
dbf files with db.in.ogr, then either
	a) link to the map attribute table with v.db.join
	b) create a view combining the cat column from the map attribute with 
the other table and use v.db.connect to link to that table

2) If the columns linking your map to the other tables are integer, you 
can also do
	- v.reclasse with 'column' option
	- v.db.connect the result of the reclass to the relevant dbf table

3 More complicated:
	- in your existing map create a new layer of cats with e.g. v.category 
map=sgdbe4_0 option=add layer=2
	- find the correspondance of the newly created cats with the cats in 
layer 1 with v.build sgbde4_0 option=cdump
	- use that information to create a new table which contains the layer 2 
cat and the key column needed to link to the other dbf tables
	- then proceed as in 1)


We really could do with an enhancement to v.category to allow the 
creation of a second layer of categories based on a column value of the 
attributes linked to the first...

Moritz


More information about the grass-user mailing list