9

Is there a way to get a list of installed gdal formats on a system with python? On the command line this can be done easily with:

gdalinfo --formats

...but can it be done in python?

10

gdal.GetDriverCount() will provide the number of drivers that gdal has. Combined with a simple loop, it is possible to list all the drivers.

import gdal
driver_list = []
for i in range(gdal.GetDriverCount()):
    driver = gdal.GetDriver(i)
    driver_list.append(driver.GetDescription())

# list comprehension
driver_list = [gdal.GetDriver(i).GetDescription() for i in range(gdal.GetDriverCount())]

# to get name as string
gdal.GetDriver(i).ShortName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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