[GRASS-user] why v.patch -e produces cat column starting from 2?

Moritz Lennert mlennert at club.worldonline.be
Wed Nov 12 09:50:45 EST 2008


On 12/11/08 15:05, Nikos Alexandris wrote:
> On Wed, 2008-11-12 at 14:44 +0100, Nikos Alexandris wrote:
>> On Wed, 2008-11-12 at 05:35 +0100, Nikos Alexandris wrote:
>>> Why isn't the cat column starting from 1 after (v.)patching vector maps
>>> (whose cat's start normally from 1)? Is it that my maps have somethig
>>> wrong? Is there a specific reason?
> 
> Following up with a WORKING example using "v.patch -a"
> 
> 
> g.copy vect=block_trier,blocks --o
> 
> # using -a flag
> v.patch -a input="block_daun" output="blocks" --o
> 
> # head of blocks is what I expect: cat(s) start with 1 :-)

That is logical, as here you do not alter the first map.

> db.select blocks | head -5
> 
> cat|AREA|PERIMETER|RAS2X2_|RAS2X2_ID|RAS2X2_NR|BLOCK|STAND|BEFL_DATUM|
> BEFL_JAHR|QUALITAET|block_id
> 1|4000000|8000|13141|13140|2558_5524|trier|01.10.2006|19.06.2005|2005||1
> 2|4000000|8000|13308|13307|2552_5522|trier|01.10.2006|19.06.2005|2005||1
> 3|4000000|8000|13310|13309|2556_5522|trier|01.10.2006|19.06.2005|2005||1
> 4|4000000|8000|13311|13310|2558_5522|trier|01.10.2006|19.06.2005|2005||1
> 
> # clean I guess is necessary when features overlap eachother.
> v.clean blocks tool=break,snap,rmdupl,rmdac thres=1,1,1 out=blocks_clean
> 
> My question(s) about why does "v.patch -e" remain :-)

There is a fundamental problem with '-a' if the cat numbers in the two 
maps are overlapping, but the attributes linked to these overlapping 
numbers are different in the two maps:

GRASS 7.0.svn (nc_spm_06):~ > v.category map1 option=print
1
2
2

GRASS 7.0.svn (nc_spm_06):~ > v.category map2 option=print
1
2

GRASS 7.0.svn (nc_spm_06):~ > v.patch -e in=map1,map2 out=result
GRASS 7.0.svn (nc_spm_06):~ > v.category result option=print
2
3
4
6
7

=>no ambiguities between cats, starts at 2, but that is not a problem as 
such

GRASS 7.0.svn (nc_spm_06):~ > v.patch -a in=map2 out=map1 --overwrite
GRASS 7.0.svn (nc_spm_06):~ > v.category map1 option=print
1
2
3
1
2

=> ambiguities between cats

This creates the following problem:

GRASS 7.0.svn (nc_spm_06):~ > v.db.select map1
cat|test
1|one
2|two
3|three

GRASS 7.0.svn (nc_spm_06):~ > v.db.select map2
cat|test
1|ten
2|twenty

GRASS 7.0.svn (nc_spm_06):~ > v.patch -a in=map2 out=map1 --overwrite

GRASS 7.0.svn (nc_spm_06):~ > v.db.select map1 cat|test
1|one
2|two
3|three

=> attributes 'ten' and 'twenty from map are gone since key fields have 
to be unique in attribute tables

So, unless you are sure that there are not overlapping cat's in the maps 
you are planning to patch, steer away from '-a'.

Moritz


More information about the grass-user mailing list