For reference, the working aggregate _expression_ is like this:
 

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

 

 

 
 
Gesendet: Montag, 23. August 2021 um 08:02 Uhr
Von: "Roland Spielhofer" <[email protected]>
An: "'qgis-user'" <[email protected]>
Betreff: Re: [Qgis-user] Length of lines in polygon depending on attribute
Hi,
I tried measure='1' and serveral variations including ' and ", but none of them returns other than NULL.
 
measure is an integer field, so measure=1 in SQL would be ok, I guess.
 
Regards,
Roland
 
 
 
Gesendet: Freitag, 20. August 2021 um 11:48 Uhr
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
_______________________________________________
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

Reply via email to