shyft.dashboard.maps.map_viewer

Classes

MapViewer()

Backend for plots of Maps with custom layers

class shyft.dashboard.maps.map_viewer.MapViewer[source]

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])

MapViewer Backend for plots of Maps with custom layers

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

  • width (int) – with of the figure

  • height (int) – height of the figure

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

__init__(*, base_map, width=300, height=300, extent_padding=0)[source]

MapViewer Backend for plots of Maps with custom layers

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

  • width (int) – with of the figure

  • height (int) – height of the figure

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

Return type:

None

add_layer(map_layer)[source]

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

Parameters:

map_layer (MapLayer)

Return type:

Tuple[Renderer, HoverTool]

update_axes()[source]

This function updates the figure axis based on layer bbox

Return type:

None