I have two shapefiles. One consists of squared grid cells and contains ... let's say precipitation data. The other one was downloaded from NaturalEarthData and contains country-internal administrative boundaries (e.g. states) ... as a mask layer. How can I add the average of the precipitation of all grid cells that are located within a mask polygon (e.g. a specific state)? Not only for one state but let's say I am actually covering the entire world.

enter image description here

1 Answer 1


You can use rasterize tool to convert the grid vector into raster. In this tool you need to choose the attribute field that represents the precipitation and choose the x and y cell sizes that matches the grid x, y spacing. The tool is located in Processing toolbox -> GDAL/OGR tools -> Analysis -> Rasterize (vector to raster) tool

enter image description here

Then use Zonal statistics to calculate the mean (average) of raster precipitation within the polygon.

enter image description here

The above workflow is for QGIS 2.14 and 2.18 and probably QGIS 3.0 (still not yet downloded).

  • Thank you for your response. I'll check it out and get back to you
    – Stücke
    Mar 8, 2018 at 12:31

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.