[GRASSLIST:5466] multiple categories and attributes
David Orme
d.orme at imperial.ac.uk
Fri Jan 21 08:27:47 EST 2005
Hi,
I have a collection of vector files with 2 category fields and I want
to link both fields into a single table so that I can use d.vect with
where to pull up combinations of the two fields (e.g. where='origin = 1
and presence=2'). I've successfully linked the two categories in to the
table but the two attributes don't seem to associate correctly. I can't
find a way of loading both categories simultaneously from the vector
into the table using v.to.db - i.e. loading the combinations of values
rather than lines of field 1 values with blank field 2 and then field2
with blank field 1. I've tried inserting the combinations using an echo
through db.execute and then connecting the vector to the table but it
doesn't still doesn't seem to hold the association between the fields.
Ultimately, I need to export the vector data and table into a
shapefile, retaining the two category fields in the shapefile
attributes.
As an example - here is the v.category output for one of the vectors
showing centroids with 2|1 and 2|2 values.
> GRASS 5.7.0:~ > v.category $testfile op=print field=1,2
> -1|-1
> -1|-1
> -1|-1
> -1|-1
> -1|-1
> -1|-1
> -1|-1
> -1|-1
> -1|-1
> -1|-1
> 2|1
> 2|1
> 2|2
> 2|1
> 2|1
> 2|1
> 2|1
> 2|1
> 2|2
> 2|1
I connect this in to a single attribute table in pgsql using:
> echo "insert into shirihai (origin, presence) values (2, 1); insert
> into shirihai (origin, presence) values (2, 2);" db.execute
> v.db.connect map=$testfile table=shirihai field=1 key=origin
> v.db.connect map=$testfile table=shirihai field=2 key=presence
However, d.vect where queries on presence (field2) display all the
areas rather than just those with the correct field2 values.
d.vect $testfile where='origin = 2' col=red # ALL ARE SHOWN - CORRECT
d.vect $testfile where='origin = 1' col=red # NONE SHOWN - CORRECT
d.vect $testfile where='presence = 2' col=red # ALL ARE SHOWN - NOT
CORRECT
d.vect $testfile where='presence = 1' col=blue # ALL ARE SHOWN - NOT
CORRECT
d.vect $testfile where='presence = 3' col=blue # NONE SHOWN - CORRECT
Can anyone point out where I'm going wrong?
many thanks,
David Orme
More information about the grass-user
mailing list