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

added keyword to GeoArray.show_map() to make figure zoomable

io.raster.GeoArray.GeoArray:
- show_map() added keyword to make figure zoomable

- updated __version__
parent 3e805bb6
......@@ -15,7 +15,7 @@ __all__=[#'compatibility',
'similarity',
'GeoArray']
__version__ = '20170315_01'
__version__ = '20170316_01'
__author__='Daniel Scheffler'
# Validate GDAL version
......
......@@ -951,7 +951,7 @@ class GeoArray(object):
def show_map(self, xlim=None, ylim=None, band=0, boundsMap=None, boundsMapPrj=None, figsize=None,
interpolation='none', cmap=None, nodataVal=None, res_factor=None, return_map=False):
interpolation='none', cmap=None, nodataVal=None, res_factor=None, return_map=False, zoomable=False):
"""
:param xlim:
......@@ -965,9 +965,20 @@ class GeoArray(object):
:param nodataVal:
:param res_factor:
:param return_map:
:param zoomable: <bool> enable or disable zooming via mpld3
:return:
"""
from mpl_toolkits.basemap import Basemap
try:
import mpld3
if zoomable:
mpld3.enable_notebook()
else:
mpld3.disable_notebook()
except:
if zoomable:
zoomable = False
warnings.warn('mpld3 is not available. Zooming disabled.')
assert self.geotransform and tuple(self.geotransform) != (0,1,0,0,0,-1),\
'A valid geotransform is needed for a map visualization. Got %s.' %self.geotransform
......@@ -1010,6 +1021,9 @@ class GeoArray(object):
palette.set_under('0')
# add image to map (y-axis must be inverted for basemap)
if zoomable:
m.imshow(image2plot, palette, interpolation=interpolation, vmin=vmin, vmax=vmax)
else:
m.imshow(np.flipud(image2plot), palette, interpolation=interpolation, vmin=vmin, vmax=vmax)
# add coordinate grid lines
......
Supports Markdown
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