Commit 22378dd6 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fix for computing wrong footprint poly if nodata value is NaN.

parent 12e1d84a
......@@ -624,8 +624,14 @@ class GeoArray(object):
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.where(arr == self.nodata, 0, 1).astype(np.bool) if arr.ndim == 2 else \
self.mask_nodata = \
np.where(arr == self.nodata, 0, 1).astype(np.bool) if arr.ndim == 2 else \
np.all(np.where(arr == self.nodata, 0, 1), axis=2).astype(np.bool)
def find_noDataVal(self, bandIdx=0, sz=3):
......@@ -995,7 +1001,7 @@ class GeoArray(object):
np.nanpercentile(image2plot.compressed(), 2), np.nanpercentile(image2plot.compressed(), 98)
palette.set_bad('aqua', 0)
else:
vmin_auto, vmax_auto = np.nanpercentile(image2plot, 2), np.percentile(image2plot, 98)
vmin_auto, vmax_auto = np.nanpercentile(image2plot, 2), np.nanpercentile(image2plot, 98)
vmin = vmin if vmin is not None else vmin_auto
vmax = vmax if vmax is not None else vmax_auto
......@@ -1110,10 +1116,11 @@ class GeoArray(object):
palette = cmap if cmap else plt.cm.gray
if nodataVal is not None and np.std(image2plot) != 0: # do not show nodata
image2plot = np.ma.masked_equal(image2plot, nodataVal)
vmin_auto, vmax_auto = np.percentile(image2plot.compressed(), 2), np.percentile(image2plot.compressed(), 98)
vmin_auto, vmax_auto = \
np.nanpercentile(image2plot.compressed(), 2), np.nanpercentile(image2plot.compressed(), 98)
palette.set_bad('aqua', 0)
else:
vmin_auto, vmax_auto = np.percentile(image2plot, 2), np.percentile(image2plot, 98)
vmin_auto, vmax_auto = np.nanpercentile(image2plot, 2), np.nanpercentile(image2plot, 98)
vmin = vmin if vmin is not None else vmin_auto
vmax = vmax if vmax is not None else vmax_auto
palette.set_over('1')
......@@ -1181,10 +1188,11 @@ class GeoArray(object):
palette = cmap if cmap else plt.cm.gray
if nodataVal is not None: # do not show nodata
image2plot = np.ma.masked_equal(image2plot, nodataVal)
vmin_auto, vmax_auto = np.percentile(image2plot.compressed(), 2), np.percentile(image2plot.compressed(), 98)
vmin_auto, vmax_auto = \
np.nanpercentile(image2plot.compressed(), 2), np.nanpercentile(image2plot.compressed(), 98)
palette.set_bad('aqua', 0)
else:
vmin_auto, vmax_auto = np.percentile(image2plot, 2), np.percentile(image2plot, 98)
vmin_auto, vmax_auto = np.nanpercentile(image2plot, 2), np.nanpercentile(image2plot, 98)
vmin = vmin if vmin is not None else vmin_auto
vmax = vmax if vmax is not None else vmax_auto
palette.set_over('1')
......
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