get_data_mask#
- get_data_mask(array: ndarray | MaskedArray, has_nodata: bool, default_nodata: int = 0) ndarray [source]#
Get nodata mask from a masked array.
The nodata may not be set before, then pass a nodata value that will be evaluated on the array.
Warning
Sets 1 where the data is valid and 0 where it is not!
Example
>>> diag_arr = np.diag([1,2,3]) array([[1, 0, 0], [0, 2, 0], [0, 0, 3]]) >>> >>> get_data_mask(diag_arr, has_nodata=False) array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype=uint8) >>> >>> get_data_mask(diag_arr, has_nodata=False, default_nodata=1) array([[0, 1, 1], [1, 1, 1], [1, 1, 1]], dtype=uint8)