<div dir="ltr"><div><div><div><div><br><br>On Thu, Dec 7, 2017 at 9:21 AM, Moritz Lennert <<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>> wrote:<br>><br>><br>><br>> Am 6. Dezember 2017 19:45:49 MEZ schrieb Peter Tittmann <<a href="mailto:ptittmann@gmail.com">ptittmann@gmail.com</a>>:<br>> >Moritz,<br>> ><br>> >v.db.connect -p c34_patch<br>> >Vector map <c34_patch> is connected by:<br>> >layer <1/c34_patch> table <c34_patch> in database<br>> ></Users/pete/grassdata/<FOO>/project_area/sqlite/sqlite.db> through<br>> >driver <sqlite> with key <cat><br>> ><br>> >So it seems that only layer 1 is connected.<br>> ><br>> >When try to connect layer 2:<br>> ><br>> >v.db.connect map=c34_patch@project_area table=c34_patch layer=2<br>> >ERROR: Use -o to overwrite existing link for layer <2><br>><br>> This is weird. This message normally only comes when there really is a connection defined for this layer:<br><br></div>The reason for the error could be that the table c34_patch is already attached to layer 1.<br><br></div>I guess what is needed here is v.db.addtable map=c34_patch layer=2<br></div><div><br></div><div>Now you could proceed as suggested by Moritz:</div><div><br></div><div>- Create a new column in layer 1 where you can put the info from layer 2<br>
- Fill this column with v.to.db option=query query_layer=2, etc<br>
- Create a second new column to hold the concatenation<br>
- v.db.update to update this new column with the concatenation of the 
two others (something like qcol = "STRATA || '_' || STAND")</div><br></div>Markus M<br><div><br><div><div><div>><br>> GRASS 7.2.2 (nc_spm_08):~ > g.copy v=hospitals,test<br>> Copy vector <hospitals@PERMANENT> to current mapset as<br>> <test><br>>  GRASS 7.2.2 (nc_spm_08):~ > v.db.connect -p test<br>> Vector map <test> is connected by:<br>> layer <1/hospitals> table <test> in database </data/home/mlennert/GRASSDATA/nc_spm_08/user1/sqlite/sqlite.db><br>> through driver <sqlite> with key <cat><br>> GRASS 7.2.2 (nc_spm_08):~ > v.db.connect test layer=2 table=test<br>> The table <test> is now part of vector map <test> and may be deleted or<br>> overwritten by GRASS modules<br>> Select privileges were granted on the table<br>> GRASS 7.2.2 (nc_spm_08):~ > v.db.connect -p test<br>> Vector map <test> is connected by:<br>> layer <1/hospitals> table <test> in database </data/hom<br>> e/mlennert/GRASSDATA/nc_spm_08/user1/sqlite/sqlite.db><br>> through driver <sqlite> with key <cat><br>> layer <2/test> table <test> in database </data/home/mlennert/GRASSDATA/nc_spm_08/user1/sqlite/sqlite.db> through driver <sqlite> with key <cat><br>> GRASS 7.2.2 (nc_spm_08):~ > v.db.connect test layer=2 table=test<br>> ERROR: Use -o to overwrite existing link for layer <2><br>><br>> So I don't really understand why you get the error message...<br>><br>> ><br>> >I’m little unclear on the ‘table’ argument, maybe that should be a now<br>> >table?<br>><br>> Although there might be situations where one could want to connect two layers to the same table, generally each layer is connected to a different table.<br>><br>> In your original post you said the vector had two layers with attributes. This does not seem to be the case when I see the v.db.connect -p output. Maybe if you go a bit back and explain to us in what format the original data is and how you imported it, this might help us help you.<br>><br>> Moritz<br>><br>> ><br>> >Thanks very much.<br>> ><br>> >Peter<br>> >> On Dec 6, 2017, at 10:27 AM, Moritz Lennert<br>> ><<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>> wrote:<br>> >><br>> >><br>> >><br>> >> Am 6. Dezember 2017 18:42:22 MEZ schrieb Peter Tittmann<br>> ><<a href="mailto:ptittmann@gmail.com">ptittmann@gmail.com</a> <mailto:<a href="mailto:ptittmann@gmail.com">ptittmann@gmail.com</a>>>:<br>> >>> Thank you, Moritz.<br>> >>><br>> >>> I'm pretty familiar with SQL but can’t figure out how layer 2 is<br>> >stored<br>> >>> in the database. When I `pragma table_info(<vector>)` I only see the<br>> >>> layer 1 attributes.<br>> >><br>> >> v.db.connect -p (or grass.script.vector_db() )will show you all<br>> >connections between the map and database tables.<br>> >><br>> >><br>> >> Moritz<br>> >>><br>> >>> I’ll work with the GRASS approach you suggested.<br>> >>><br>> >>> Best,<br>> >>> Peter<br>> >>><br>> >>><br>> >>>> On Dec 1, 2017, at 11:53 PM, Moritz Lennert<br>> >>> <<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>> wrote:<br>> >>>><br>> >>>> On 02/12/17 02:03, Peter Tittmann wrote:<br>> >>>>> Hi,<br>> >>>>> I have a vector (`POINT`) which has two layers containing relevant<br>> >>> attributes (’strata’ and ’stand’). I would like to concatenate the<br>> >two<br>> >>> values into a new attribute for Layer 1 (’<STRATA>_<STAND>’). I’ve<br>> >been<br>> >>> struggling to sort this out for too long and am tapping out. Its<br>> >>> probably blatantly obvious but it has escaped me.<br>> >>>><br>> >>>><br>> >>>> Probably the easiest way if your not very familiar with SQL:<br>> >>>><br>> >>>> - Create a new column in layer 1 where you can put the info from<br>> >>> layer 2<br>> >>>> - Fill this column with v.to.db option=query query_layer=2, etc<br>> >>>> - Create a second new column to hold the concatenation<br>> >>>> - v.db.update to update this new column with the concatenation of<br>> >the<br>> >>> two others (something like qcol = "STRATA || '_' || STAND")<br>> >>>><br>> >>>> Otherwise, if there is a common key in both tables, you can just<br>> >>> create a new column and use db.execute to launch a UPDATE TABLE<br>> >>> directly, grabbing the info from the two table and concatenating it<br>> >>> directly in the query.<br>> >>>><br>> >>>> Moritz<br>> >>>><br>> >>>><br>> >>>>> Thank you!<br>> >>>>> Here are some specifics.<br>> >>>>> east, north: 651849.842735, 6604949.78485<br>> >>>>> c34_patch@project_area:<br>> >>>>>  Type: Point<br>> >>>>>  Id: 21622<br>> >>>>>  Layer: 1<br>> >>>>>  Category: 21623<br>> >>>>>  Driver: sqlite<br>> >>>>>  Database:<br>> >>> /Users/pete/grassdata/PortGraham/project_area/sqlite/sqlite.db<br>> >>>>>  Table: c34_patch<br>> >>>>>  Key_column: cat<br>> >>>>>  Attributes:<br>> >>>>>    cat: 21623<br>> >>>>> *strata: 3  — STRATA*<br>> >>>>> c34_patch@project_area:<br>> >>>>>  Type: Point<br>> >>>>>  Id: 21622<br>> >>>>>  Layer: 2<br>> >>>>> *Category: 10  — STAND*<br>> >>>>> _______________________________________________<br>> >>>>> grass-user mailing list<br>> >>>>> <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a> <mailto:<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>><br>> ><mailto:<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a> <mailto:<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>>><br>> >>>>> <a href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a><br>> ><<a href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a>><br>> >>> <<a href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a><br>> ><<a href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a>>><br>> _______________________________________________<br>> grass-user mailing list<br>> <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>> <a href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a><br><br></div></div></div></div></div>