In GIS operations you must care about coordinate reference system (CRS) of each file. You must learn a little bit about it before doing this kind of processes. Landsat images are distributed in a cartesian CRS, not a geographic CRS. What does this mean? The coordinate unit of a Landsat scene is meter, not degree. GDALinfo("myraster.tif") is showing you ...


If you are using ArcGIS the tool you are looking for is Zonal Statistics. You can mark out your your areas of interest with a shape file or feature class, and then use this as input along with your geotiff. I think QGIS has a similar zonal statistics tool if that's the software you are using.


You have to delete the output dataset to make sure the script releases that object from memory (although it should do it at the end of the exectution). You can do this by adding del outdata at the end of your script. I always use both band.FlushCache() (which writes the data to disk) and del outdata to make sure I don't end up with an empty array.

Only top voted, non community-wiki answers of a minimum length are eligible