map_display module

class MapDisplay(map_type, aar_var, inputs, states, get_data_func, clickdata_func=None, output_var=None, label=None, colorscale='YlGn')

Bases: object

Module used for creating a map visualization.

When supplied with a get_data_func that returns data grouped by a valid geography it creates a map figure with coloring showing the column ‘value’ on different geographical units. Important! If making a map for ‘kommune’, your variable needs to be named ‘komm_nr’ and for fylke it needs to be named ‘fylke_nr’.

Note

You need read access to the bucket “areal-data-delt-kart-prod” in order to use this module as this is where it finds the shapefiles.

Parameters:
  • map_type (str)

  • aar_var (str)

  • inputs (list[str])

  • states (list[str])

  • get_data_func (Callable[[...], Any])

  • clickdata_func (Callable[[...], Any] | None)

  • output_var (str | None)

  • label (str | None)

  • colorscale (str)

create_map_figure()

Creates the map figure.

Return type:

Figure

get_data(*args)

Gets data for the map figure by using get_data_func.

Return type:

None

Parameters:

args (Any)

get_geoshape(year)

Gets the parquet file with geometry from the shared bucket.

Return type:

None

Parameters:

year (str)

is_valid()

Does some validation checks for the module.

Return type:

None

layout()

Define the layout for the MapDisplay module.

Because this module can be used as a a component in other modules, it needs to have a layout method that is not abstract. For implementations as tab or window, this method should still be overridden.

Returns:

A Dash HTML Div component representing the layout of the module to be displayed directly.

Return type:

html.Div

module_callbacks()

Registers module callbacks.

Return type:

None

supported_map_types: ClassVar[list[str]] = ['kommune', 'fylke']
class MapDisplayTab(map_type, aar_var, inputs, states, get_data_func, clickdata_func=None, output_var=None, label=None, colorscale='YlGn')

Bases: TabImplementation, MapDisplay

MapDisplay implemented as a Tab.

Parameters:
  • map_type (str)

  • aar_var (str)

  • inputs (list[str])

  • states (list[str])

  • get_data_func (Callable[[...], Any])

  • clickdata_func (Callable[[...], Any] | None)

  • output_var (str | None)

  • label (str)

  • colorscale (str)

class MapDisplayWindow(map_type, aar_var, inputs, states, get_data_func, clickdata_func=None, output_var=None, label=None, colorscale='YlGn')

Bases: WindowImplementation, MapDisplay

MapDisplay implemented as a Window.

Parameters:
  • map_type (str)

  • aar_var (str)

  • inputs (list[str])

  • states (list[str])

  • get_data_func (Callable[[...], Any])

  • clickdata_func (Callable[[...], Any] | None)

  • output_var (str | None)

  • label (str)

  • colorscale (str)

mapdisplay_default_clickdata(clickdata)

Default clickdata function. Returns the number for the clicked kommune / fylke.

Return type:

str

Parameters:

clickdata (dict[str, list[dict[str, Any]]])