[gdal-dev] Gdal_warp -r sum not working a expected

Andrew C Aitchison andrew at aitchison.me.uk
Fri Jul 1 12:39:28 PDT 2022


On Fri, 1 Jul 2022, Ainslie Johnstone wrote:

> Hi there,
>
> I am trying to downsample a high-resolution file of gridded
> population estimates (1km res over the whole world). I want the
> downsampled version to give the total population in the new
> lower-resolution grid. However, whenever I downsample using gdalwarp
> -r sum, I don’t seem to be getting this. Instead the new values in
> the lower-resolution grid (no matter what resolution it is) seem to
> be more like the max, rather than the sum, of the old
> high-resolution grid. If I add up the total population across the
> whole grid it is far lower than it should be. How much lower depends
> on how much I have downsampled.
>
> I am making sure to exclude the no data values, and have tried a
> whole variety of different output resolutions and projections. Any
> suggestions as to why this might be?

1. Are your working type -wt and output type -ot big enough to store
the population of the new pixels ?

2. If you don't need to record nodata, you could *try* making the
nodata value 0 and treat them as data.

-- 
Andrew C. Aitchison                      Kendal, UK
                    andrew at aitchison.me.uk


More information about the gdal-dev mailing list