1

In a QGIS composer, I would like to add a text label with the calculation of % of length of the total layer with a specific feature value.

My layer is composed of roads lines and I would like to know the proportion of the total length which have a specific value, like 'good' for the "ROADCONDITION" field.

For another question I had a good answer for count function:

'Existing roads: '
|| round(aggregate('releve_terrain','count', ' ',"ROADEXIS" = 'Yes') / layer_property('releve_terrain','feature_count') *100)  || '%'

I am looking for some help to use another function.

  • try using the 'sum' aggregate expression instead of 'count' – csk Mar 22 '18 at 17:57
  • Do I need to create a field with length to do so? Then use something like 'Existing roads: ' || round(aggregate('releve_terrain','sum', "length","ROADEXIS" = 'Yes') / layer_property('releve_terrain','feature_count') *100) || '%' Or the sum function works always with the $lenght ? – Arthur Mar 23 '18 at 8:57
  • I would expect that function to work with $length, but the best way to find out is to try it out. – csk Mar 23 '18 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.