Commit bbb2622b authored by Daniel Scheffler's avatar Daniel Scheffler

Added parameter 'ax' to GeoArray.show().

parent 584ab3ef
Pipeline #3189 passed with stages
in 1 minute and 25 seconds
......@@ -1031,7 +1031,7 @@ class GeoArray(object):
def show(self, xlim=None, ylim=None, band=None, boundsMap=None, boundsMapPrj=None, figsize=None,
interpolation='none', vmin=None, vmax=None, pmin=2, pmax=98, cmap=None, nodataVal=None,
res_factor=None, interactive=False):
res_factor=None, interactive=False, ax=None):
"""Plots the desired array position into a figure.
:param xlim: [start_column, end_column]
......@@ -1052,6 +1052,7 @@ class GeoArray(object):
plotting time and memory (default=None -> downsampling is performed to 1000x1000)
:param interactive: <bool> activates interactive plotting based on 'holoviews' library.
NOTE: this deactivates the magic '% matplotlib inline' in Jupyter Notebook
:param ax: <matplotlib.axis> only usable in non-interactive mode
:return:
"""
......@@ -1112,10 +1113,13 @@ class GeoArray(object):
'Switching to standard matplotlib figure..') # TODO implement zoomable fig
# show image
plt.figure(figsize=figsize)
if not ax:
plt.figure(figsize=figsize)
ax = plt.gca()
rows, cols = image2plot.shape[:2]
plt.imshow(image2plot, palette, interpolation=interpolation, extent=(0, cols, rows, 0),
vmin=vmin, vmax=vmax, ) # compressed excludes nodata values
ax.imshow(image2plot, palette, interpolation=interpolation, extent=(0, cols, rows, 0),
vmin=vmin, vmax=vmax, ) # compressed excludes nodata values
plt.show()
def show_map(self, xlim=None, ylim=None, band=0, boundsMap=None, boundsMapPrj=None, ax=None, figsize=None,
......@@ -1355,11 +1359,11 @@ class GeoArray(object):
self.clip_to_poly(self.footprint_poly)
def clip_to_poly(self, poly):
# type: (Polygon) -> None
"""Clip the GeoArray instance to the outer bounds of a given shapely polygon.
:param poly: instance of shapely.geometry.Polygon
"""
# type: Polygon -> None
self.arr, self.gt, self.projection = self.get_mapPos(mapBounds=poly.bounds, mapBounds_prj=self.prj)
self.mask_nodata.arr, self.mask_nodata.gt, self.mask_nodata.projection = \
self.mask_nodata.get_mapPos(mapBounds=poly.bounds, mapBounds_prj=self.prj)
......
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