Requirement:
- refFunctions plugin to use
geomnearest()
and dbvalue()
.
- QGIS version: 2.16 or 2.18 to use
concatenate()
expression in aggregate group.
As your Lines-Points
is in 1-N relationship
, most Field Calculator
tasks have to be done on Point
layer.
(1) On your "element_ep" Point
Layer attributes, create a new text field (let's call it line
) by:
geomnearest('reseau_ep', 'numero')
// This will add name of corresponding (nearest) line for each point.
// 'reseau_ep' is your target layer, which is the Line layer
// 'numero' is your line number in Line layer attributes
// NB. put them in single quotation marks.
(2) Also on the Point
layer create a new string field (let's say strings
) by:
concatenate("nu_affaire", group_by:="line", concatenator:=', ')
// This will create a concatenated text of nu_affaire, grouped by linenames obtained above.
// Note double quotation marks to wrap fields, and single for ', '.
Then close Point
layer attribute table and go to "reseau_ep" Line
layer
(3) Open attribute table of your Line
layer and start Field Calculator. Create a new text field (shall we call it outcome
?)
dbvalue('element_ep', 'strings', 'line', numero)
// This will lookup your Point layer (element_ep) and extract strings field.
// The condition is `line` = numero; i.e. key=`line` and value=numero
// NB. (again) put them in single quotation marks, except for numero (which is Value).
Final product is your Line
layer attribute table, which has an outcome
field in which you find combined text of all the points (nu_affairs) per each line.