I am overlaying a polygon layer with shapes representing cities over a 0.5 x 0.5 km shapefile grid. Each grid cell has an associated GDP value representing the entire GDP of said grid cell.

The workflow as I'm thinking through it would go something like this:

  • Calculate percentage of coverage of overlayed city polygon layer for each grid cell
  • Multiply percentage of coverage by associated grid value
  • If city polygon is overlayed over multiple grid cells, add all values based on percentage of each associated grid cell coverage
  • Append GDP to existing city polygon layer


  • Grid cell 1 = 10

  • Grid cell 2 = 30

  • City polygon 1 = 25% coverage of grid cell 1; 15% coverage of grid cell 2

  • City polygon 2 = 50% coverage of grid cell 1

  • City polygon 1 GDP = (0.25x10)+(0.15x30) = 2.5 + 4.5 = 7.0

  • City polygon 2 GDP = 0.50x10 = 5.0

For reference, the data I'm using is sourced from a paper conducting research on gridding global GDP based on SSP scenarios.

Another similar dataset is from SEDAC.

I have already tried the overlap analysis tool. Main issue I'm running into is not distinction between city polygons if overlaid on one grid cell since the overlap analysis tool only gives one percentage and one area per grid cell

  • I'm sure many of the frequent answerers here can come up with the script to do it all in QGIS, but for a start you could run the overlay analysis tool, recalculate any area fields you want, then export/copy the attribute table to Excel or similar spreadsheet program and analyze the results there as in a pivot table. When done you could join the results to your original city polygon layer.
    – John
    Nov 28, 2022 at 22:01
  • Thanks for the comment. I have tried the overlap analysis tool, but the main issue with it is that as far as I can tell there's not way to distinguish one polygon from another from the overlaid polygon layer. So in my case, if there's two city polygons that partially overlay a single grid cell, I have no way of telling the exact percentage the grid cell is covered by either polygon. The overlap analysis tool just gives one percentage output for each grid cell, regardless if more than one polygon is overlaid. Not sure if there's a workaround to this. Nov 28, 2022 at 22:53
  • 1
    You might edit your question to include what you have tried, including what you just mentioned in the comment, to help others. Can you switch the input and overlay layers and use that? If both the city poly and grid cell poly have unique attributes prior to the overlay (if not add them) you could run a union overlay, recalculate the area fields and then export/copy to the pivot table and calculate percentages and additional values.
    – John
    Nov 28, 2022 at 23:10


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.

Browse other questions tagged or ask your own question.