I have three lines as per the below picture. The layer is called 'line'. A is 60m, B is 30m and C is 90m. I have a polygon layer consisting of 1 square. The layer is called 'polygon'.
I want to make a calculated field called "ttl_length"
in the polygon layer which is the total length of all lines that pass through the polygon. In other words, the total should be 180m.
I am currently using the below-calculated field:
aggregate(layer:='line',
aggregate:='sum',
expression:= "line_length" ,
filter:=intersects(geometry(@parent), $geometry)
)
The above will only give me the sum of the length of lines actually inside the square. I need the length of all the lines (eg. 180m). How can I do that?