# Rescale raster to custom resolution using sum as the function to aggregate

I have a 0.0083 resolution population raster dataset which I would like to upscale to a 0.5 resolution raster. In particular, I would like the aggregation process to sum all the 0.0083 pixels contained each into of the new 0.5 grid cells. This way, each 0.5 cell contains a value which is the sum of all the original 0.0083 cells which are underlying it.

I am familiar with QGIS, R, or Python.

Depending of how accurate the results need to be, you may not need to actually perform a "sum" resampling.

Resampling can be wieved as computing a (weighted) mean of neighbouring pixels, then attributing this mean to the output pixels.

Therefore, an approximate solution to your issue consists in performing a regular resampling (a bilinear filter would be sufficient); then you just have to multiply the resulting raster by the pixel surface ratio (in your case, (0.5/0.0083)^2 = 3629).

Of course, this won't work if you use more complex resampling filters (such as bicubic filter) or if you want to directly resample a lat/lon raster (which is a bad idea anyway).

One simple solution would be to create a vector grid (fishnet) of 0.5 degrees resolution, that is the same size as your input image and then use zonal stats to calculate the sum for each cell. You can then rasterize the shapefile to get the image you want.

QGIS has a 'vector grid' tool under vector > research tools, and QGIS also has a very good zonal stats plugin.

Not a VERY elegant solution but im not sure if a 'sum' resampling method exists. It is 100% possible in python/R, but for a single dataset the vector approach will be faster. You could also create the vector grid in python/R if you know how and then you could automate the process easily from there on.