Can you provide me with Python code to read metadata from a raster file?
3 Answers
Two options:
- Use GDAL Python bindings.
- Run GDALINFO from python and capture the stdout, to get a string with the metadata:
import os
metadata = os.popen('gdalinfo ../rasterfile.tiff').read()
print metadata
from osgeo import gdal
filename=gdal.Open("file path")
metadata=filename.GetMetadata()
print(metadata)
-
Even if the answer is simple, coding answers should also contain words describing the solution (and, ideally, a documentation reference). "Wall of code" answers are likely to receive a similar response to "Wall of code" questions (down-voting and removal). Please take the Tour to get a better idea of how GIS SE operates.– VinceJan 12, 2020 at 17:20