geoinfo.py 文件源码

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

项目:uncover-ml 作者: GeoscienceAustralia 项目源码 文件源码
def numpy_band_stats(ds, tif, band_no, partitions=100):
    band = ds.GetRasterBand(band_no)
    data = band.ReadAsArray()
    no_data_val = band.GetNoDataValue()
    data_type = get_datatype(band)
    mask_data = ma.masked_where(data == no_data_val, data)

    if data_type is 'Categorical':
        no_categories = np.max(mask_data) - np.min(mask_data) + 1
    else:
        no_categories = np.nan

    image_source = geoio.RasterioImageSource(tif)
    l = [basename(tif), band_no, no_data_val,
         ds.RasterYSize, ds.RasterXSize,
         np.min(mask_data), np.max(mask_data),
         np.mean(mask_data), np.std(mask_data),
         data_type, float(no_categories),
         image_nans(image_source, partitions)]
    ds = None
    return [str(a) for a in l]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号