Search code examples
python-3.xgdal

Adding a progress bar to gdal.Translate()


Similar to Adding Progress Bar to gdal.Warp() but for python 3. How to add a progress bar to gdal.Translate() in a python script?


Solution

  • Turns out theres a callback function provided with the gdal python bindings called TermProgress_nocb.

    Example:

    # gdal_translate with progressbar
    _ = gdal.Translate(
        *args, 
        callback=gdal.TermProgress_nocb,
        **kwargs,
    )
    
    # Write output to disc
    _ = None
    

    Prints:

    0...10...20...30...40...50...60...70...80...90...100 - done.
    

    I discovered this while exploring osgeo_utils.auxiliary.