2

I'm trying to downsample population data downloaded from https://www.worldpop.org/geodata/summary?id=24777 to lower resolution using the following command

gdalwarp -tr 0.1 0.1 -co TILED=YES -co COMPRESS=LZW /home/ppp_2020_1km_Aggregated.tif /home/ppp_2020_downsampled.tif

However the statistics for downsampled GeoTiff file are wildly different:

ORIGINAL:

  Metadata:
    STATISTICS_MAXIMUM=672314.9375
    STATISTICS_MEAN=36.107581341026
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=382.17835506557
    STATISTICS_VALID_PERCENT=27.29

DOWNSAMPLED:

  Metadata:
    STATISTICS_MAXIMUM=198223773696
    STATISTICS_MEAN=79130.423171493
    STATISTICS_MINIMUM=-258876342272
    STATISTICS_STDDEV=743223866.17039
    STATISTICS_VALID_PERCENT=27.03

For instance the minimum of population should obviously never go negative. The default resampling method near shouldn't cause this either. Is there something obvious I'm missing?

Joonas
  • 121
  • 1

1 Answers1

0

Here is my result using QGIS 3.12 on Windows 10.

enter image description here

Ralph Tee
  • 1,722
  • 12
  • 17
  • Thanks for trying! Must be something in my environment then.. – Joonas May 05 '20 at 06:37
  • 2
    So apparently the statistics are cached to aux.xml files. I kept deleting and re-warping into a file with the same name .tif, but didn't touch the xml file with now outdated information. Deleting the xml file helped – Joonas May 05 '20 at 06:41
  • In the past, I had came across output discrepancies between the Windows and Linux versions of GDAL/OGR tools. – Ralph Tee May 05 '20 at 06:41
  • You can also compute statistics again with the gdal_edit python script https://gdal.org/programs/gdal_edit.html. – user30184 May 05 '20 at 07:18