Commit eef1b430 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

added keywords vmin, vmax

io.raster.GeoArray.GeoArray:
- show(): added keywords "vmin" and "vmax"
- show_map(): added keywords "vmin" and "vmax"
- show_map_utm(): added keywords "vmin" and "vmax"

- updated __version__
parent 8d78e630
......@@ -15,7 +15,7 @@ __all__=[#'compatibility',
'similarity',
'GeoArray']
__version__ = '20170328_01'
__version__ = '20170330_01'
__author__='Daniel Scheffler'
# Validate GDAL version
......
......@@ -881,7 +881,7 @@ class GeoArray(object):
def show(self, xlim=None, ylim=None, band=None, boundsMap=None, boundsMapPrj=None, figsize=None,
interpolation='none', cmap=None, nodataVal=None, res_factor=None, interactive=False):
interpolation='none', vmin=None, vmax=None, cmap=None, nodataVal=None, res_factor=None, interactive=False):
"""Plots the desired array position into a figure.
:param xlim: [start_column, end_column]
......@@ -892,6 +892,8 @@ class GeoArray(object):
:param boundsMapPrj:
:param figsize:
:param interpolation:
:param vmin:
:param vmax:
:param cmap:
:param nodataVal:
:param res_factor:
......@@ -912,10 +914,14 @@ 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, vmax = np.percentile(image2plot.compressed(),2), np.percentile(image2plot.compressed(),98)
vmin_auto, vmax_auto = np.percentile(image2plot.compressed(),2), np.percentile(image2plot.compressed(),98)
palette.set_bad('aqua', 0)
else:
vmin, vmax = np.percentile(image2plot, 2), np.percentile(image2plot, 98)
vmin_auto, vmax_auto = np.percentile(image2plot, 2), np.percentile(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')
palette.set_under('0')
......@@ -951,7 +957,8 @@ class GeoArray(object):
def show_map(self, xlim=None, ylim=None, band=0, boundsMap=None, boundsMapPrj=None, ax=None, figsize=None,
interpolation='none', cmap=None, nodataVal=None, res_factor=None, return_map=False, zoomable=False):
interpolation='none', vmin=None, vmax=None, cmap=None, nodataVal=None, res_factor=None,
return_map=False, zoomable=False):
"""
:param xlim:
......@@ -962,6 +969,8 @@ class GeoArray(object):
:param ax: allows to pass a matplotlib axis object where figure is plotted into
:param figsize:
:param interpolation:
:param vmin:
:param vmax:
:param cmap:
:param nodataVal:
:param res_factor:
......@@ -1014,16 +1023,16 @@ 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, vmax = np.percentile(image2plot.compressed(), 2), np.percentile(image2plot.compressed(), 98)
vmin_auto, vmax_auto = np.percentile(image2plot.compressed(), 2), np.percentile(image2plot.compressed(), 98)
palette.set_bad('aqua', 0)
else:
vmin, vmax = np.percentile(image2plot, 2), np.percentile(image2plot, 98)
vmin_auto, vmax_auto = np.percentile(image2plot, 2), np.percentile(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')
palette.set_under('0')
# add image to map (y-axis must be inverted for basemap)
#vmin=None # TODO make this adjustable
#vmax=None
if zoomable:
m.imshow(image2plot, palette, interpolation=interpolation, vmin=vmin, vmax=vmax)
else:
......@@ -1044,8 +1053,8 @@ class GeoArray(object):
plt.show()
def show_map_utm(self, xlim=None, ylim=None, band=0, figsize=None, interpolation='none', cmap=None, nodataVal=None,
res_factor=None, return_map=False):
def show_map_utm(self, xlim=None, ylim=None, band=0, figsize=None, interpolation='none', cmap=None,
nodataVal=None, vmin=None, vmax=None, res_factor=None, return_map=False):
from mpl_toolkits.basemap import Basemap
warnings.warn(UserWarning('This function is still under construction and may not work as expected!'))
......@@ -1080,10 +1089,12 @@ 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, vmax = np.percentile(image2plot.compressed(), 2), np.percentile(image2plot.compressed(), 98)
vmin_auto, vmax_auto = np.percentile(image2plot.compressed(), 2), np.percentile(image2plot.compressed(), 98)
palette.set_bad('aqua', 0)
else:
vmin, vmax = np.percentile(image2plot, 2), np.percentile(image2plot, 98)
vmin_auto, vmax_auto = np.percentile(image2plot, 2), np.percentile(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')
palette.set_under('0')
......
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