Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, obj, paths=None, **params):
super(LineCrossSection, self).__init__(**params)
self.obj = obj
paths = [] if paths is None else paths
self.path = Path(paths, crs=ccrs.GOOGLE_MERCATOR)
self.path_stream = PolyDraw(source=self.path,
num_objects=self._num_objects)
PolyEdit(source=self.path)
self.sections = Dynamic(self.obj, operation=self._sample,
streams=[self.path_stream])
self.tiles = WMTS(self.tile_url)
def callback(self):
return (gv.WMTS(self.tile_server) * gv.tile_sources.StamenLabels())
from bokeh.io import curdoc
from bokeh.models import WMTSTileSource
from holoviews.operation.datashader import datashade, aggregate, shade
from holoviews.plotting.util import fire
shade.cmap = fire
hv.extension('bokeh')
renderer = hv.renderer('bokeh').instance(mode='server')
# Load data
ddf = dd.read_parquet('../data/nyc_taxi_hours.parq/').persist()
from bokeh.models import WMTSTileSource
url = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.jpg'
wmts = gv.WMTS(WMTSTileSource(url=url))
stream = hv.streams.Stream.define('HourSelect', hour=0)()
points = hv.Points(ddf, kdims=['dropoff_x', 'dropoff_y'])
dmap = hv.util.Dynamic(points, operation=lambda obj, hour: obj.select(dropoff_hour=hour).relabel('Hour of Day: %d' % hour),
streams=[stream])
# Apply aggregation
aggregated = aggregate(dmap, link_inputs=True, streams=[hv.streams.RangeXY], width=1200, height=600)
# Shade the data
class ColormapPicker(hv.streams.Stream):
colormap = param.ObjectSelector(default=cm["fire"],
objects=[cm[k] for k in cm.keys() if not '_' in k])
cmap_picker = ColormapPicker(rename={'colormap': 'cmap'}, name='')
shaded = shade(aggregated, link_inputs=True, streams=[cmap_picker])
def __init__(self, polys=None, points=None, crs=None, **params):
super(GeoAnnotator, self).__init__(**params)
plot_opts = dict(height=self.height, width=self.width)
self.tiles = WMTS(self.tile_url, extents=self.extent,
crs=ccrs.PlateCarree()).opts(plot=plot_opts)
polys = [] if polys is None else polys
points = [] if points is None else points
crs = ccrs.GOOGLE_MERCATOR if crs is None else crs
self._tools = [CheckpointTool(), RestoreTool(), ClearTool()]
if not isinstance(polys, Path):
polys = self.path_type(polys, crs=crs)
self._init_polys(polys)
if not isinstance(points, Points):
points = Points(points, self.polys.kdims, crs=crs)
self._init_points(points)