def rasterize_geom(geom, shape, affine, all_touched=False):
"""
Parameters
----------
geom: GeoJSON geometry
shape: desired shape
affine: desired transform
all_touched: rasterization strategy
Returns
-------
ndarray: boolean
"""
geoms = [(geom, 1)]
rv_array = features.rasterize(
geoms,
out_shape=shape,
transform=affine,
fill=0,
dtype='uint8',
all_touched=all_touched)
return rv_array.astype(bool)
# https://stackoverflow.com/questions/8090229/
# resize-with-averaging-or-rebin-a-numpy-2d-array/8090605#8090605
评论列表
文章目录