aggregate( layer:='line_layer', aggregate:= 'sum', _expression_:="Length",
filter:=("measure"=1 AND contains( @atlas_geometry, $geometry )))
this calculates the total length of all line features that are contained in the current atlas coverage layer (polygon layer in my case) and have the value 1 in the field "measure".
The trick is the geometry _expression_ that restricts the length calculation to a certain polygon.
Field names need double quotes.
Regards,
Roland
Von: "Roland Spielhofer" <[email protected]>
An: "'qgis-user'" <[email protected]>
Betreff: Re: [Qgis-user] Length of lines in polygon depending on attribute
Von: "Phil Wyatt" <[email protected]>
An: "'Roland Spielhofer'" <[email protected]>, "'qgis-user'" <[email protected]>
Betreff: RE: [Qgis-user] Length of lines in polygon depending on attribute
Hi Roland,
I am assuming measure is a field name so what happens if you try measure=’1’?
Cheers - Phil
From: Qgis-user <[email protected]> On Behalf Of Roland Spielhofer
Sent: Friday, 20 August 2021 7:20 PM
To: qgis-user <[email protected]>
Subject: [Qgis-user] Length of lines in polygon depending on attribute
Hi,
I have a polygon layer and a line layer.
I would like to update a field in the polygon layer with the length of the lines in each polygon that have a certain value in an attribute.
I thought I use the field calculator and the aggregate function but I did not succeed.
What I have now is:
aggregate( layer:='line_layer', aggregate:= 'sum', _expression_:='length', filter:='measure=1')
which returns NULL
In the line layer there is an attribute 'length' that already holds the length of the element.
I only want the lines that have the attribute "measure=1".
Any help appreciated!
Regards,
Roland
_______________________________________________ Qgis-user mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
