def clean_mask(rast):
'''
Clips the values in a mask to the interval [0, 1]; values larger than 1
become 1 and values smaller than 0 become 0.
Arguments:
rast An input gdal.Dataset or numpy.array instance
'''
# Can accept either a gdal.Dataset or numpy.array instance
if not isinstance(rast, np.ndarray):
rastr = rast.ReadAsArray()
else:
rastr = rast.copy()
return np.clip(rastr, a_min=0, a_max=1)
评论列表
文章目录