TransWikia.com

Using values of a coma-separated list to arrange and extend attribute table in QGIS

Geographic Information Systems Asked by Alice123 on December 2, 2020

In my attribute table (neighbors) there is a comma-separated list in which the IDs of adjacent polygons are located. But now I want one line to appear for each adjacent polygon. So there would be e.g. (check the picture below) the line with the oid DENW17ALxE000051DENW17AL00003neWTF twice. Once with the adjacent polygon DENW17ALW600005aDENW17ALZb00007HTF and once with this one DENW17ALW600005dDENW17AL00003pGQTF. It was just an example, I would need it for every single line.

If there is no way to regulate this using the comma-separated list, I think another formula would have to be specified in the previous step (field calculator). So that the result is not the comma-separated list, but an attribute table extended by rows. I entered the following into the field calculator:

aggregates (
 layer: = 'street polygons',
 aggregate: = 'concatenate',
 expression: = oid,
 concatenator: = ',',
 filter: = intersects ($ geometry, geometry (@parent))
 )

attribute table
simplified scheme. in blue the table of attributes as it is now, in orange as it should be with addition (wertigkeit_neighbor)

One Answer

Try "Split features by character" (in the Processing Toolbox > Vector general) tool.

An example:

(1) Prepared a small test case: one point with neighbors field, with a record 'aaa, bbb'

enter image description here

(2) Started Split features by character tool.

Split value is a comma. Also please take notice of a small space after the comma. (Pointed by the red arrow, between the comma and the black caret mark).

enter image description here

(3) Ran the tool, then it returned a new Split layer, with duplicated geometries of aaa and bbb values.

enter image description here

Answered by Kazuhito on December 2, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP