Re: Copy and concatenate a vector attribute between layers

Moritz Lennert <[email protected]>
Newsgroups gmane.comp.gis.grass.user
Message-ID <[email protected]>
On 02/12/17 02:03, Peter Tittmann wrote:
> Hi,
> 
> I have a vector (`POINT`) which has two layers containing relevant 
> attributes (’strata’ and ’stand’). I would like to concatenate the two 
> values into a new attribute for Layer 1 (’<STRATA>_<STAND>’). I’ve been 
> struggling to sort this out for too long and am tapping out. Its 
> probably blatantly obvious but it has escaped me.


Probably the easiest way if your not very familiar with SQL:

- Create a new column in layer 1 where you can put the info from layer 2
- Fill this column with v.to.db option=query query_layer=2, etc
- Create a second new column to hold the concatenation
- v.db.update to update this new column with the concatenation of the 
two others (something like qcol = "STRATA || '_' || STAND")

Otherwise, if there is a common key in both tables, you can just create 
a new column and use db.execute to launch a UPDATE TABLE directly, 
grabbing the info from the two table and concatenating it directly in 
the query.

Moritz


> 
> Thank you!
> 
> Here are some specifics.
> 
> 
> east, north: 651849.842735, 6604949.78485
> c34_patch@project_area:
>    Type: Point
>    Id: 21622
>    Layer: 1
>    Category: 21623
>    Driver: sqlite
>    Database: /Users/pete/grassdata/PortGraham/project_area/sqlite/sqlite.db
>    Table: c34_patch
>    Key_column: cat
>    Attributes:
>      cat: 21623
> *strata: 3  — STRATA*
> c34_patch@project_area:
>    Type: Point
>    Id: 21622
>    Layer: 2
> *Category: 10  — STAND*
> 
> 
> _______________________________________________
> grass-user mailing list
> [email protected]
> https://lists.osgeo.org/mailman/listinfo/grass-user
> 

_______________________________________________
grass-user mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.