[GRASS-dev] [GRASS GIS] #2641: Copy cat value to a new layer does not work

#2641: Copy cat value to a new layer does not work
--------------------------+-------------------------
  Reporter: pvanbosgeo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.3
Component: Vector | Version: unspecified
Resolution: | Keywords: attribute
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by mlennert):

Replying to [ticket:2641 pvanbosgeo]:
> I have a vector map with layer=1 linked to attribute table and layer=2
providing the number of overlapping categories. Aim is to create a third
layer with unique values for each feature/polygon. The third step below,
uploading the cat values from layer 2 to layer 3 doesn't work.
>
> # Add layer 3 to the vector layer test
>
> # add attribute table
> v.category test op=add layer=3 type=centroid out=test2
> v.db.addtable test2 layer=3 column="cat2 integer"
>
> # Upload cat from layer 2 to layer 3
> v.to.db test2 layer=3 query_layer=2 op=cat columns=cat2

AFAIK query_layer is only used for op=query (and op=sides), but not for
op=cat.

Currently, if you need to get the cats of another layer, you have to
create an attribute table linked to that layer and the use op=query to get
the cat values, although I don't know what will happen with a layer 2 as
yours where some features have several cat values...

BTW, I tried to test the case where you want to upload cat values to a new
column (not the key column) to see how v.to.db handles uploading several
cat values for a single feature, but v.to.db chokes on that since before
uploading cat values it tests whether these value already exist in the key
column of the database, even if you want to upload these values to another
column than the key column... But that should probably be documented in
another bug report.

In brief, I wouldn't consider this a bug (or at most a documentation bug),
as uploading cat values into one column in the case where a feature might
have several values is not clearly defined...

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2641#comment:5&gt;
GRASS GIS <https://grass.osgeo.org>