def get_stats(tif, partitions=100):
ds = gdal.Open(tif, gdal.GA_ReadOnly)
number_of_bands = ds.RasterCount
if ds.RasterCount > 1:
d = {}
log.info('Found multibanded geotif {}'.format(basename(tif)))
for b in range(number_of_bands):
d['{tif}_{b}'.format(tif=tif, b=b)] = band_stats(ds, tif, b + 1,
partitions)
return d
else:
log.info('Found single band geotif {}'.format(basename(tif)))
return {tif: band_stats(ds, tif, 1, partitions)}
评论列表
文章目录