Suppose you have
import xarray as xr
import hvplot.xarray as hvplot
import holoviews as hv
from holoviews import opts
from holoviews.streams import PolyDraw
import numpy as np
hv.extension('bokeh')
ds = xr.tutorial.load_dataset('air_temperature')
base_map = ds.air.hvplot.image(
'lon', 'lat',
geo=True,
frame_height=400,
frame_width=600,
cmap='RdYlBu_r',
coastline=True
)
# Create PolyDraw stream
poly_draw = PolyDraw(source=base_map)
# Create dynamic map that updates based on drawn polygons
def dynamic_map_callback(polygons):
pass
# Create the dynamic map
dmap = hv.DynamicMap(dynamic_map_callback, streams=[poly_draw])
Can someone help me write a basic skeleton for such a stream?
Right now I have a Tap Stream hooked to the hvplot.image object that produces a time series plot but I also want to calculate statistics on a user defined subset of the map (select polygon that is used to cut out the data and use .mean
, .min
, .max
etc. on it)