You can use aggregate()
with an intersects()
filter:
aggregate(
'ok_ak_riks',
'concatenate',
"kommunkod",
filter:=intersects($geometry,end_point(geometry(@parent))),
concatenator:=','
)
Previous / alternative answer:
array_to_string(
array_filter(
array_foreach( -- 2. iterate over ALL intersecting features
overlay_intersects('ok_ak_riks',$currentfeature), -- 1. get ALL intersecting features
if(
intersects(geometry(@element),end_point($geometry)), -- 3. check if the current one intersects with the lines endpoint
attribute(@element,'kommunkod'), -- 4a. if it does, return the attribute
'' -- 4b. otherwise return an empty string
)
),
@element <> '') -- 5. filter out the empty strings from the array
)
Explanation:
you can first get all intersecting features as array by using overlay_intersects('ok_ak_riks',$currentfeature)
, then iterate over this array by using array_foreach()
and filter to the intersecting ones with your endpoint by testing if the current one intersects with your endpoint if(intersects(geometry(@element),end_point($geometry))
. This will return the feature of ok_ak_riks
intersecting with the lines end. At this point you will get an array like ['','your attribute','','']
where you never know at which position your value is. So you can use array_filter(array,@element <> '')
to remove all empty values.