1

How do I use python to find raster layer properties like

The GDAL driver and/or description used to load a raster in QGIS

For Example : for a Tif 'GTiff' and 'GeoTiff' or
       for an ESRI Grid 'AIG' and 'Arc/Info Binary Grid'

For a vectors you use layer.dataProvider().storageType() but when applied to a raster layer it returns AttributeError: 'QgsRasterDataProvider' object has no attribute 'storageType'

I'm using QGIS 3.10

1 Answer 1

2

QGIS uses GDAL behind the scene and only exposes infos as HTML e.g iface.activeLayer().htmlMetadata(). So to get the infos, I would use the following:

from osgeo import gdal

layer = iface.activeLayer()
dataset = gdal.Open(layer.dataProvider().dataSourceUri(), gdal.GA_ReadOnly)

print(dataset.GetDriver().ShortName)
print(dataset.GetDriver().LongName)

Your Answer

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

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