def inspect(input_dir, report_file, partitions, extension):
input_dir = abspath(input_dir)
if isdir(input_dir):
log.info('Reading tifs from {}'.format(input_dir))
tifs = glob.glob(join(input_dir, '*.' + extension))
else:
log.info('Reporting geoinfo for {}'.format(input_dir))
tifs = [input_dir]
with open(report_file, 'w', newline='') as csvfile:
writer = csv.writer(csvfile, dialect='excel')
writer.writerow(['FineName', 'band', 'NoDataValue', 'rows', 'cols',
'Min', 'Max', 'Mean', 'Std',
'DataType', 'Categories', 'NanCount'])
process_tifs = np.array_split(tifs, mpiops.chunks)[mpiops.chunk_index]
stats = [] # process geotiff stats including multibanded geotif
for t in process_tifs:
stats.append(get_stats(t, partitions))
# gather all process geotif stats in stats dict
stats = _join_dicts(stats)
# global gather in root
stats = _join_dicts(mpiops.comm.gather(stats, root=0))
if mpiops.chunk_index == 0:
for k, v in stats.items():
write_rows(v, writer)
评论列表
文章目录