Commit d97a4ad9 authored by Daniel Scheffler's avatar Daniel Scheffler

Fixed issue #15 (ValueError: 'axis' entry is out of bounds).

parent 3cb75aaf
Pipeline #2645 passed with stages
in 1 minute and 27 seconds
......@@ -637,16 +637,20 @@ class GeoArray(object):
assert self.ndim in [2, 3], "Only 2D or 3D arrays are supported. Got a %sD array." % self.ndim
arr = self[:, :, fromBand] if self.ndim == 3 and fromBand is not None else self[:]
if self.nodata is None:
self.mask_nodata = np.ones((self.rows, self.cols), np.bool)
elif np.isnan(self.nodata):
self.mask_nodata = \
np.invert(np.isnan(arr)) if arr.ndim == 2 else \
np.all(np.invert(np.isnan(arr)), axis=2)
min_v, max_v = np.min(arr), np.max(arr)
if (min_v == max_v == self.nodata) or (np.isnan(min_v) and np.isnan(max_v) and np.isnan(self.nodata)):
self.mask_nodata = np.full(arr.shape[:2], False)
else:
self.mask_nodata = \
np.ma.masked_not_equal(arr, self.nodata).mask if arr.ndim == 2 else \
np.all(np.ma.masked_not_equal(arr, self.nodata).mask, axis=2)
if self.nodata is None:
self.mask_nodata = np.ones((self.rows, self.cols), np.bool)
elif np.isnan(self.nodata):
self.mask_nodata = \
np.invert(np.isnan(arr)) if arr.ndim == 2 else \
np.all(np.invert(np.isnan(arr)), axis=2)
else:
self.mask_nodata = \
np.ma.masked_not_equal(arr, self.nodata).mask if arr.ndim == 2 else \
np.all(np.ma.masked_not_equal(arr, self.nodata).mask, axis=2)
def find_noDataVal(self, bandIdx=0, sz=3):
"""Tries to derive no data value from homogenious corner pixels within 3x3 windows (by default).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment