1

In QGIS, I have two vector layers - one vector layer is basically a grid, where each grid cell is of size 100x100m, while the other vector layer is Building Footprints data (a collection of polygons representing building outlines).

My requirement is to calculate the Mean Patch Area and Patch Count for every grid cell. I am trying to estimate these two metrics through the "Join Attributes By Location (Summary)" function -- but when I do so, I'm getting unexpected results.

These are the settings with which I executed the above function:

enter image description here

After execution, most of the grid cells are displaying the Mean Patch Area and Patch Count as expected - however, there are certain edge cases that are causing some issues. Consider this scenario, where a patch is overlapping with 2 grid cells:

enter image description here

My requirement is that the Grid Cell on the Top will only consider the portion of the patch that falls inside it, meaning that the Mean Patch Area will be very small when compared to the Mean Patch Area calculated for the Bottom Grid Cell. However, that doesn't seem to be the case; the Mean Patch Areas for the Top and the Bottom Grid cells are close (201 m.sq. and 245 m.sq.).

How, then, do I run this function such that such edge cases are also correctly estimated? I am trying with other predicates (overlap, contains etc.) as well - will update once I know more.

1
  • Would "Multipart to Singleparts" split that overlapping patch into two different patches in the two grid cells? If so, how exactly would I use it? When I checked, this tool takes in only one single input layer. Sep 21, 2023 at 8:58

1 Answer 1

3
  1. I have 2 layers: Buildings and Grid

enter image description here

  1. I use "Split with Lines" algorithm and set the tool as below:

enter image description here

The output will be polygons split by the border lines of each grid cell.

enter image description here

  1. We need to add the ID of the cell into each resulting part of the polygon after splitting it by using the "Intersection" algorithm.

enter image description here

Below is the resulting layer:

enter image description here

  1. Let's open the attribute table of "Intersection" layer: (Now we know each part belongs to which grid number)

enter image description here

  1. We can then calculate the area of each polygon part using the "Field calculator":

enter image description here

enter image description here

  1. You should be able to calculate the statistics from the resulting table:

enter image description here

  1. You can use the "Statistics by Categories" algorithm to calculate statistics based on the Area and the category being the ID of the Grid.

enter image description here

In short, as long as you can create the parts in each grid and assign the Grid ID they are in, you could also calculate the area, from there generate all sorts of statistics.

I would use QGIS Graphical Modeller if I had to redo this operation often.

6
  • I think "Overlap Analysis" doesn't give me exactly what I need - it will calculate the total patch area and percentage per grid cell, but not the Patch Count or Mean Patch Area. Sep 21, 2023 at 8:43
  • Understood, let me refine my solution.
    – GforGIS
    Sep 21, 2023 at 9:08
  • Actually my bad, your answer is almost there. It was able to calculate the area of the patch for each grid cell separately instead of considering the entire area of the patch. I can use this to calculate Mean Patch Area then. Sep 21, 2023 at 9:12
  • @Gamma-ray-burst let me know if this pointer works for you.
    – GforGIS
    Sep 21, 2023 at 9:54
  • Yes, this is pretty much what I required, I appreciate it! My only final issue would be that since my dataset has a ton of polygons that overlap, the "Split with Lines" tool would result in an explosion of new features and a massive file size - but I think that would be unavoidable. At any rate, this is a good solution. Sep 22, 2023 at 16:19

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.