[GRASSLIST:10119] v.to.db option=query: issue with 2 layers and multiple categories

  The problem:

  In case when a vector in layer 2 has more than one categories
  assigned, and in layer 1 it has only one category, v.to.db
  option=query fails to copy attributes from layer 1 to layer 2,
  due to "Multiple query results, output value set to NULL". Is
  this a bug in v.to.db? I would expect both layer 2 datatables to
  be populated with the same value, not NULL.

  The whole story. I hope you will make it to read it:

  I had a vector line made of two parts, connected with a node. I
  have converted it to points (v.to.points). As a result 2 points
  were created at that node. So I removed one duplicate with
  v.clean. Now this point attributes look like this (d.what.vect):

598394.0625(E) 5681271.65625(N)

testing_pt_nodupl2 in melio Point
Layer: 1
category: 2
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_1
key column: cat
cat : 2
height : 100.500000
Layer: 2
category: 11
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_2
key column: cat
cat : 11
lcat : 2
along : 0.000000
Layer: 1
category: 1
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_1
key column: cat
cat : 1
height : 100.500000
Layer: 2
category: 10
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_2
key column: cat
cat : 10
lcat : 1
along : 890.245313

  I wanted to populate the "height" from layer 1 to layer 2.
  First I'll create a column to be populated with "height" values:

v.db.addcol map=testing_pt_nodupl layer=2 col="z double"

  Now, when I tried to populate all the "height" attributes from
  layer 1 to "z" in layer 2 a problem occured:

v.to.db map=testing_pt_nodupl2 type=point layer=2 qlayer=1 option=query
column=z qcolumn=height Reading data trom the map ...

Querying database ...

Multiple query results, output value set to NULL (category 11)

Multiple query results, output value set to NULL (category 10)
Updating database ...

17 categories read from map
17 records selected from table
17 categories read from map exist in selection from table
0 categories read from map don't exist in selection from table
17 records updated/inserted
0 update/insert errors

  In spite of "0 update/insert errors" actually there _are_
  errors, due to "Multiple query results". Only 16 points have
  their "z" populated with "height" as needed. The vector point
  having the both 10 and 11 category (due to v.clean), has the
  attribute "z" not set, as d.what.vect says:

598394.0625(E) 5681271.65625(N)

testing_pt_nodupl2 in melio Point
Layer: 1
category: 2
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_1
key column: cat
cat : 2
height : 100.500000
Layer: 2
category: 11
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_2
key column: cat
cat : 11
lcat : 2
along : 0.000000
z :
Layer: 1
category: 1
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_1
key column: cat
cat : 1
height : 100.500000
Layer: 2
category: 10
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_2
key column: cat
cat : 10
lcat : 1
along : 890.245313
z :

  Is this a bug in v.to.db? I would expect both categories 10 and
  11 to be assinged the same "z", not none.

  I might be simply not getting something here. I will appreciate
  any comments.

Maciek

--------------------
W polskim Internecie s? setki milion?w stron. My przekazujemy Tobie tylko najlepsze z nich!
http://katalog.panoramainternetu.pl/

Hi,
I am satisfied to read that people are using and understand these
more complex features in GRASS vector model.

I think (I hope) that the problem is that you have more cats
(1,2) in the layer 1 on the point. If you use qcolumn=height
v.to.db queries the database for this point with
  select height from testing_pt_nodupl2_1 where cat=1 or cat=2
The result is 2 rows (100.5 twice). It is impossible to upload
2 values into one row in layer 2. If you have more cats in queried
layer on the same geometry it is necessary to use an aggregate
function, for example qcolumn=avg(height).

Does it work?

Radim

On 2/1/06, Maciek Sieczka <werchowyna@epf.pl> wrote:

        The problem:

        In case when a vector in layer 2 has more than one categories
        assigned, and in layer 1 it has only one category, v.to.db
        option=query fails to copy attributes from layer 1 to layer 2,
        due to "Multiple query results, output value set to NULL". Is
        this a bug in v.to.db? I would expect both layer 2 datatables to
        be populated with the same value, not NULL.

        The whole story. I hope you will make it to read it:

        I had a vector line made of two parts, connected with a node. I
        have converted it to points (v.to.points). As a result 2 points
        were created at that node. So I removed one duplicate with
        v.clean. Now this point attributes look like this (d.what.vect):

598394.0625(E) 5681271.65625(N)

testing_pt_nodupl2 in melio Point
Layer: 1
category: 2
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_1
key column: cat
cat : 2
height : 100.500000
Layer: 2
category: 11
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_2
key column: cat
cat : 11
lcat : 2
along : 0.000000
Layer: 1
category: 1
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_1
key column: cat
cat : 1
height : 100.500000
Layer: 2
category: 10
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_2
key column: cat
cat : 10
lcat : 1
along : 890.245313

        I wanted to populate the "height" from layer 1 to layer 2.
        First I'll create a column to be populated with "height" values:

v.db.addcol map=testing_pt_nodupl layer=2 col="z double"

        Now, when I tried to populate all the "height" attributes from
        layer 1 to "z" in layer 2 a problem occured:

v.to.db map=testing_pt_nodupl2 type=point layer=2 qlayer=1 option=query
column=z qcolumn=height Reading data trom the map ...

Querying database ...

Multiple query results, output value set to NULL (category 11)

Multiple query results, output value set to NULL (category 10)
Updating database ...

17 categories read from map
17 records selected from table
17 categories read from map exist in selection from table
0 categories read from map don't exist in selection from table
17 records updated/inserted
0 update/insert errors

        In spite of "0 update/insert errors" actually there _are_
        errors, due to "Multiple query results". Only 16 points have
        their "z" populated with "height" as needed. The vector point
        having the both 10 and 11 category (due to v.clean), has the
        attribute "z" not set, as d.what.vect says:

598394.0625(E) 5681271.65625(N)

testing_pt_nodupl2 in melio Point
Layer: 1
category: 2
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_1
key column: cat
cat : 2
height : 100.500000
Layer: 2
category: 11
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_2
key column: cat
cat : 11
lcat : 2
along : 0.000000
z :
Layer: 1
category: 1
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_1
key column: cat
cat : 1
height : 100.500000
Layer: 2
category: 10
driver: dbf
database: //home/grassdata/caves_utm33/melio/dbf/
table: testing_pt_nodupl2_2
key column: cat
cat : 10
lcat : 1
along : 890.245313
z :

        Is this a bug in v.to.db? I would expect both categories 10 and
        11 to be assinged the same "z", not none.

        I might be simply not getting something here. I will appreciate
        any comments.

Maciek

--------------------
W polskim Internecie s? setki milion?w stron. My przekazujemy Tobie tylko najlepsze z nich!
http://katalog.panoramainternetu.pl/

On Thu, 2 Feb 2006 09:41:10 +0100
Radim Blazek <radim.blazek@gmail.com> wrote:

Radim,

Hi,
I am satisfied to read that people are using and understand these
more complex features in GRASS vector model.

I think (I hope) that the problem is that you have more cats
(1,2) in the layer 1 on the point.

If you use qcolumn=height v.to.db queries the database for this point
with select height from testing_pt_nodupl2_1 where cat=1 or cat=2
The result is 2 rows (100.5 twice). It is impossible to upload
2 values into one row in layer 2. If you have more cats in queried
layer on the same geometry it is necessary to use an aggregate
function, for example qcolumn=avg(height).

Does it work?

Right! There are indeed two categories in layer 1, for the same
geometry element. Now that you made me notice it it's obvious wy the
error, thanks.

However, there are _also_ two categories for the same geometry in layer
2 (10,11). I mean - I understand I couldn't upload 2 values into one
"row". But since in this particular case in both layer 1 and 2 there
are two "rows", isn't it somehow different? Just wondering.

Best,
Maciek

--------------------
W polskim Internecie s? setki milion?w stron. My przekazujemy Tobie tylko najlepsze z nich!
http://katalog.panoramainternetu.pl/

On 2/3/06, Maciek Sieczka <werchowyna@epf.pl> wrote:

On Thu, 2 Feb 2006 09:41:10 +0100
Radim Blazek <radim.blazek@gmail.com> wrote:

Radim,

> Hi,
> I am satisfied to read that people are using and understand these
> more complex features in GRASS vector model.
>
> I think (I hope) that the problem is that you have more cats
> (1,2) in the layer 1 on the point.

> If you use qcolumn=height v.to.db queries the database for this point
> with select height from testing_pt_nodupl2_1 where cat=1 or cat=2
> The result is 2 rows (100.5 twice). It is impossible to upload
> 2 values into one row in layer 2. If you have more cats in queried
> layer on the same geometry it is necessary to use an aggregate
> function, for example qcolumn=avg(height).
>
> Does it work?

Right! There are indeed two categories in layer 1, for the same
geometry element. Now that you made me notice it it's obvious wy the
error, thanks.

However, there are _also_ two categories for the same geometry in layer
2 (10,11). I mean - I understand I couldn't upload 2 values into one
"row". But since in this particular case in both layer 1 and 2 there
are two "rows", isn't it somehow different? Just wondering.

If it is not uploaded to both rows in layer 2 (10,11) then it is a bug.

Radim

Best,
Maciek

--------------------
W polskim Internecie s? setki milion?w stron. My przekazujemy Tobie tylko najlepsze z nich!
http://katalog.panoramainternetu.pl/