3

I have encountered a problem that I thought would be much more simple than I see it actually is, and conventional clipping did not work.

I have the following grid layer with different values of a field in each varying-sized cell:

enter image description here

I want to fit these values into the following census group polygons for a certain county:

enter image description here

This of course becomes a challenge since some block groups are completely contained within the cells and some overlap between multiple cells. I am trying to find the best way to "distribute" the values in the cells to the block group polygons. My best guess is that this distribution should be weighted by area, such that if three block groups cross into a cell, the value of the cells will be distributed between the block groups proportional to the area of each of these block groups. I think this would be called area-weighted interpolation.

Can this be done simply in QGIS?

When I tried clipping, with the cells as my input layer and the block groups as my overlay layer, I got this, which is not what I want:

enter image description here

2 Answers 2

1

In the groups layer, compute a new field with the following expression:

aggregate(
  'cells',
  'sum',
  "value" *
  area(
    intersection(
      $geometry,
      geometry(
        @parent))) /
  area(
    geometry(
      @parent)),
  intersects(
    $geometry,
    geometry(
      @parent)))

Where cells is the name of the grid layer and value is the name of the values field in that layer.

The expression searches the features in the cells layer for those whose geometry intersects each geometry in the block layer.
On the features found, the value that it contributes is computed, weighed by the proportion of the intersection area on the area of the original (blocks group) geometry. Finally, it groups all the features found by applying and returning the sum function to the previous expression as an attribute.

1

Just confirming your language here

  • Cells - the gridded layer
  • Block Groups - the census group polygons

The 'clip' operation you have done above will give you an output of the cells geometry part, which is within the block group. BUt it will also aggregate the clipped features. Use an 'intersect' instead which will maintain the geometry records. This output will have an area. If you compare this to the original area, this will give you the area ratio. eg: Original area = 100, intersected area = 75.... Therefore weighted value = 0.75

So the approach I would take is:

  • expose the area of the original cell as an attribute in the source data (You can do this by creating a new field on your source data and assign it the area of the geometry using the Field Calculator)
  • Perform an intersect as per above.
  • On your new 'intersected_cells' layer, create a new field called 'ratio'. This field will be equal to 'New Area divided by original area. As above, create new field, using field calculator.

You now have your weighted value.

2
  • Hi. I think the tool should be Intersection. The purpose of the Clip tool is to clip the source layer to the contours of the cut layer, as long as they are not adjacent. That is why the set of blocks is considered as a single geometry at the time of cutting. Aug 9, 2021 at 2:11
  • oh yer of course! That was the first thing I thought of and then totally forgot to change it in my answer! ill fix it up now. no argument here.
    – nr_aus
    Aug 9, 2021 at 6:05

Your Answer

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

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