4

I am looking for a tool that can give me an area-weighted average.

I have a shapefile of parcels and another shapefile with Curve Numbers. I want to get Area Weighted CN for each parcel. If I do it manually, I would first intersect parcels with the Curve Number file. Recalculated Area for each feature in the intersected shapefile. Take the attributes to Excel and then use the Pivot table or Vlookup to find the sum of areas and sum of (CN*Area of each feature) for a particular parcel and then divide them to get the Area Weighted Curve Number.

Is there a tool to do it automatically in QGIS?

enter image description here

0

2 Answers 2

2

You can do it with SQL (Virtual Layers) with ST_INTERSECTION (documentation), or do the intersection layer between your parcel layer and the curve number layer, and update the final parcel layer field with the following expression :

aggregate(
  layer:= 'Intersection',
  aggregate:= 'sum',
  expression:= "CN" * area($geometry),
  filter:= "id" = attribute(@parent, 'id')
)
/
aggregate(
  layer:= 'Intersection',
  aggregate:= 'count',
  expression:= "CN",
  filter:= "id" = attribute(@parent, 'id')
)

You can after do a simple processing model with an intersection of two polygon layers and compute a new field with the above expression.

2
  • My question was looking for a specific already made tool that can do the job. But based on your idea I am working on developing a python script. I have some questions on it and will ask them as a separate question. I will put the link of that question here as a comment. Feb 19, 2020 at 18:54
  • here is the link for that question gis.stackexchange.com/questions/351329/… Feb 19, 2020 at 23:41
1

Feeling the need for such a tool. I developed a Plugin myself to do area weighted average.

https://plugins.qgis.org/plugins/area_weighted_average/

Download it from inside QGIS via plugin in manager (make sure to enable experimental plugins) or from here:

https://plugins.qgis.org/plugins/area_weighted_average/

enter image description here

2
  • thanks, I tried your tool but it was very slow so i killed the process after a couple of days. I was thinking, could you not achieve the same result by rasterizing the vector layer and then using Zonal Statistics? that could also be much less computationally intensive
    – ffgg
    Apr 22 at 13:32
  • There is something wrong if it is taking more than a few minutes, or you are doing it on Terrabytes of data. Please file a bug report here github.com/ar-siddiqui/area_weighted_average and attach your data so that I can investigate. Apr 23 at 18:20

Your Answer

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

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