GDALRaster Info

gdalinfo

What is gdalinfo?

gdalinfo is the GDAL command-line utility for inspecting raster datasets. It prints the driver, pixel dimensions, coordinate reference system, geotransform, corner coordinates, band data types, NoData values, statistics, and embedded metadata. If GDAL has a driver for it — GeoTIFF, JPEG2000, NetCDF, HDF5, MBTiles, COG, Sentinel SAFE, anything — gdalinfo will tell you what is inside without opening the file in a desktop GIS.

Shell
gdalinfo [options] <dataset>

Commonly used options:

  • -json — emit machine-readable JSON instead of the default text report
  • -stats — compute and report min/max/mean/stddev per band (persists to aux.xml)
  • -hist — report histogram per band
  • -mm — force computation of approximate min/max
  • -nogcp, -nomd, -norat, -noct — suppress GCPs, metadata, raster attribute tables, or colour tables
  • -checksum — compute a per-band checksum for integrity comparisons
  • -proj4 — additionally print the CRS in PROJ.4 form
  • -listmdd / -mdd <domain> — list or fetch specific metadata domains (e.g. IMAGE_STRUCTURE, SUBDATASETS)

When would you use gdalinfo?

Reach for gdalinfo at the start of every ingest or QA workflow. Typical uses: confirming that a delivered orthomosaic carries the expected CRS before you reproject, checking that NoData is set correctly on a DEM after preprocessing, inspecting band count and data type on a Sentinel-2 or Landsat product, or extracting the geotransform to sanity-check pixel size and alignment against a reference grid.

It is also the fastest way to discover subdatasets inside container formats like NetCDF, HDF5, or GRIB — gdalinfo my.nc lists each variable as a subdataset path you can then feed into gdal_translate. In scripting, gdalinfo -json scene.tif | jq .cornerCoordinates gives you a structured payload for pipelines without parsing human-oriented text.

FAQs

Why does gdalinfo say "Computed Min/Max" is missing?

By default gdalinfo only reports statistics that are already cached in the file or its sidecar .aux.xml. Pass -stats to force GDAL to scan the raster and compute them; results are written to the aux file so subsequent calls are instant. Use -mm for a quick approximate min/max that uses overviews when available.

How do I read metadata out of a NetCDF or HDF5 file?

Container formats expose their variables as subdatasets. Run gdalinfo on the outer file to see lines like SUBDATASET_1_NAME=NETCDF:"file.nc":temperature. Pass that full subdataset string back into gdalinfo or gdal_translate to work with the individual variable. -mdd all dumps every metadata domain, useful for attributes that do not appear in the default output.

What is the difference between gdalinfo and ogrinfo?

gdalinfo works on raster datasets; ogrinfo works on vector datasets. A GeoPackage or a PostGIS connection with both raster tiles and vector layers may respond to both tools, but each only sees its own data model. If a file refuses to open with one, try the other before assuming corruption.

Can I use gdalinfo output in automated pipelines?

Yes — always use -json. The text output is human-oriented and its layout has changed between releases; the JSON schema is stable and parses cleanly in any language. Combine with jq for quick field extraction (e.g. gdalinfo -json scene.tif | jq -r .coordinateSystem.wkt) or load it directly in Python with json.loads.