GeoTIFFs made in GDAL don't have min/max range when loaded in Arc/QGIS
If you're generating the data, then you can keep track of the min and max on the fly. If you don't have direct control of the source data, say if you are compositing existing data, then using ComputeRasterMinMax(0)
is fine.
Either way, after you've got your min and max values, you should call SetStatistics()
on the band, and ensure you set your dataset to None
when you've finished to ensure everything gets written to disk.
Also, something in the back of my mind is telling me using dataset.GetRasterBand(1).<some band function>
won't work properly because of the way GDAL Python handles band references. I can't remember the details, but there was something on the GDALDev mailing list some time ago. So it's best to create a band variable explicitly: band = dataset.GetRasterBand(1)
, then call band.SetStatistics(min, max, mean, stddev)
.