geoinfo.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:uncover-ml 作者: GeoscienceAustralia 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号