3

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

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. – ar-siddiqui Feb 19 '20 at 18:54
  • here is the link for that question gis.stackexchange.com/questions/351329/… – ar-siddiqui Feb 19 '20 at 23:41
0

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

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.