4

I have a vector layer which includes the acreage of the different features, I want to calculate the sum acreage of all polygons with

Parcel size >400 acres
Parcel size <100acres
Parcel size >100acres
Parcel size > 1000acres

screenshot of attribute table

1
  • 2
    The simplest way is to run a selection query for your four different groups and then hit the Vector - Analysis - Basic Statistics for Fields for each. You could instead run the Group Stats plugin for a more "elegant" solution or just export the data to a spreadsheet for a pivot table analysis
    – John
    Commented Mar 29, 2023 at 11:04

2 Answers 2

5

You can categorise your features using a field calculator expression such as this (in this case the output field is called size_range):

case 
    when acres <= 100 then 'lte_100'
    when acres > 100 and acres <= 400 then 'gt_100_and_lte_400'
    when acres > 400 and acres <= 1000 then 'gt_400_and_lte_1000'
    when acres > 1000 then 'gt_1000'
end

And then use the Statistics by categories tool:

enter image description here

enter image description here

4

Solution: array aggregate

Use aggregate function array_agg() with a filter, where area is the attribute field where the parcel size of each polygon is stored:

array_sum (array_agg (area, filter:="area" < 100))

Advanced: all four values at once

To get all four values at once as an array, use this expression:

array_foreach(
    array ('<100','>100','>400','>1000'),
    eval ('array_sum (array_agg (area, filter:= area' || @element  || '))')
)

The expression, added with a round() function, shows the four sums in the preview: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.