I know how to create the overviews to a specific geoTIFF file using GDAL ( i have tested it in QGIS), but I cannot find any good information on how to read these overviews individually in Python.

gdal.SetConfigOption('HFA_USE_RRD', 'YES')
outData = gdal.Open("test2.tiff",gdal.GA_Update)

i would expect the answer to be something like:

array = outData.GetOverviews(overviewlist = 2)
  • 2
    How about outdata.GetOverview(2)?
    – Kersten
    Feb 16, 2016 at 15:02
  • It seems like i dont have that function. i have just installed the OSgeo4w64, is this function not available? Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'Dataset' object has no attribute 'GetOverview' >>>
    – William
    Feb 17, 2016 at 8:12
  • I checked my gdal version. it says: 1.11.3
    – William
    Feb 17, 2016 at 8:48

2 Answers 2


The reason to my problem was that I was not calling the function from the right class. GetOverview is called from the class Band.


Here is the python gdal code to extract overview from Sentinel 2 JP2 format with overview level 2 (0-index).

import gdal
jp2 = "T32UMD_20190727T104029_TCI_10m.jp2"

dataset = gdal.Open(jp2)

band1 = dataset.GetRasterBand(1);
overview1 = band1.GetOverview(2);

band2 = dataset.GetRasterBand(2);
overview2 = band2.GetOverview(2);    

band3 = dataset.GetRasterBand(3);
overview3 = band3.GetOverview(2);

arr1 = overview1.ReadAsArray()
arr2 = overview2.ReadAsArray()
arr3 = overview3.ReadAsArray()

[cols, rows] = arr1.shape

driver = gdal.GetDriverByName("GTiff")
outdata = driver.Create("test_overview.tiff", rows, cols, 3, gdal.GDT_Byte)


outdata.FlushCache() ##saves to disk!!
outdata = None

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.