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

Ainslie Johnstone johnstone.ainslie at gmail.com
Mon Jul 4 01:20:00 PDT 2022


Hi All, 

Thanks for your comments. I replaced the no data value (which previously was -200) with zero and then it all seemed to work!

Best wishes, 
Ainslie 

> On 1 Jul 2022, at 20:39, Andrew C Aitchison <andrew at aitchison.me.uk> wrote:
> 
> 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 <mailto:andrew at aitchison.me.uk>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220704/1dc30931/attachment-0001.htm>


More information about the gdal-dev mailing list