def readBandMetaData(inputFile, band, name):
# Open the dataset in Read Only mode
dataset = gdal.Open(inputFile, gdal.GA_ReadOnly)
# Check that the image has opened
if not dataset is None:
# Get the image band
imgBand = dataset.GetRasterBand(band)
# Check the image band was available
if not imgBand is None:
# Get the meta data value specified
metaData = imgBand.GetMetaDataItem(name)
# Check that it is present
if metaData == None:
# If not present, print error.
print("Could not find \'", name, "\' item.")
else:
# Else print out the metadata value
print(name, "=\'", metaData, "\'")
else:
# Print out an error message.
print("Could not open the image band: ", band)
else:
# Print an error message if the file
# could not be opened.
print("Could not open the input image file: ", inputFile)
# A function to read a meta-data item
# from an image
readBandMetaData.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录