Determining driver, spatial reference and other props from an open GDAL layer

Geographic Information Systems Asked by auslander on December 14, 2020

I have a very large network share full of data (raster, vector, sometimes mixed inside of geopackage and/or file geodatabase containers). I have a set of classes that crawl through it all and use arcpy.Describe() to extract from each dataset its datatype, extent and spatial reference system. That then goes into a single enterprise db layer that shows our spatial holdings and a bit of heritage data of each element.

I’d like to try making it open source for other users to run who do not have licenses. GDAL also offers me some more insight into what specific driver is being used, to further categorize the data, theoretically.

I’d like to avoid hardcoding around file extensions and ask GDAL (or fiona, or shapely, not picky here) instead – [update] because I don’t know what sort of files the indexer will encounter. Assuming a subset of the data, I can do something like this:

import gdal

filelist = [

for f in filelist:
        dataset = gdal.Open(f)
        # do stuff

but I am not clear how to then summon the properties of dataset (I’m presuming that the open dataset object holds the elements I’m looking for). I’ve looked at but there is nothing I can find that says "here is how you get all the properties of an gdal.Open() object."

Ultimately the properties I want to see would be presented something like this:

    "driver": "GPKG",
    "driver_long_name": "GeoPackage raster"
    "type": "Raster",
    "extent": [(miny, minx), (maxy, minx), (maxy, maxx), (miny, maxx)]
    "CRS" : {'epsg:4326'}

One Answer

gdal.Info might be the simplest way:

ds = gdal.Open('/vsicurl/')
info = gdal.Info(ds, options='-json')

dict_keys(['description', 'driverShortName', 'driverLongName', 'files', 'size', 'coordinateSystem', 'geoTransform', 'metadata', 'cornerCoordinates', 'wgs84Extent', 'rat', 'bands'])

But if you want to figure out how to pull that information directly from the open Dataset object look at the methods that start with Get in the documentation for gdal.Dataset.

Answered by user2856 on December 14, 2020

Add your own answers!

Related Questions

Exporting from QGIS to .dxf as blocks?

0  Asked on September 3, 2021 by andrea-z


Getting meters from pgr_dijkstra

1  Asked on September 3, 2021


Problem with custom Projection

1  Asked on September 3, 2021 by programmer1234567


Save multiple raster files as shapefiles

1  Asked on September 3, 2021 by zigmod


Publishing PostGIS Rasters in GeoServer?

2  Asked on September 3, 2021 by asp


QGIS Problem loading or adding WFS Layer

1  Asked on September 2, 2021


Setting up CRS for Mars images taken by a satellite

1  Asked on September 2, 2021 by user7587298


Shapefile in leaflet shifted North 0.25°

1  Asked on September 2, 2021 by stefan-gofferje


How to bind to coordinates , in sld GeoServer?

1  Asked on September 1, 2021 by develop-qurtino


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir