shyft.dashboard.maps.map_viewer

Classes

MapViewer(*, base_map[, width, height, ...])

Backend for plots of Maps with custom layers

class shyft.dashboard.maps.map_viewer.MapViewer(*, base_map: BaseMap, width: int = 300, height: int = 300, extent_padding: float = 0)

Bases: object

Backend for plots of Maps with custom layers

Examples

from statkraft.bokeh.maps.map_viewer import MapViewer
from statkraft.bokeh.maps.layer_data import LayerDataHandle
from statkraft.bokeh.maps.map_layer import MapLayer
from statkraft.bokeh.test.maps.test_map_fixtures import basemap_factory

# initialisation
base_map = basemap_factory()
# create map viewer
map_viewer = MapViewer(width=300, height=300, base_map=base_map, extent_padding=10)
# add layer
layer1 = MapLayer(map_viewer=map_viewer, name=’first layer’, layer_type=LayerType.POINT,
glyph_fixed_kwargs={‘radius’: 5},
glyph_variable_kwargs={‘x’: ‘x’, ‘y’: ‘y’},
)
# update the data with layer_data_handle
min_x = 26621 + 22373*0.5 + 50
min_y = 6599653 + 18731*0.5 + 50
max_x = 26621 + 22373*0.5 + 100
max_y = 6599653 + 18731*0.5 + 100

updated_data = {‘x’: [min_x, max_x],
‘y’: [min_y, max_y]}
layer_data_handle = LayerDataHandle(map_layer=layer1, data=updated_data)

map_viewer.receive_layer_data_handles([layer_data_handle])
__init__(*, base_map: BaseMap, width: int = 300, height: int = 300, extent_padding: float = 0) None

MapViewer Backend for plots of Maps with custom layers

Parameters:
  • base_map – BaseMap instance to use in the back ground

  • width – with of the figure

  • height – height of the figure

  • extent_padding – extra padding for the axis, when snapping to all objects in layers

add_layer(map_layer: MapLayer) Tuple[Renderer, HoverTool]

Function to add a new layer to the Map This is called from the Layer constructor

update_axes() None

This function updates the figure axis based on layer bbox