BokehMapOutlines#
- class dtcg.interface.plotting.BokehMapOutlines[source]#
Bases:
BokehMapHandler for plotting glacier outlines on a map.
- defaults#
Default options for all Bokeh figures.
- Type:
dict
- hover_tool#
Hover tool for Bokeh figures.
- Type:
bokeh.models.HoverTool
- palette#
Colour palette.
- Type:
tuple[str]
- tooltips#
A list of tooltips corresponding to a polygon’s metadata. By default, these are:
Name
RGI ID
GLIMS ID
Area
Max Elevation
Min Elevation
Latitude
Longitude
Outline Date
- Type:
list
Methods
__init__()Check holoviews is installed to prevent silent failures.
decode_datacube(datacube)Get a dataset decoded into CF conventions.
Get all valid preset colour palettes.
get_color_palette(name)Get a preset palette.
Default options for Bokeh figures.
get_help_button(text[, position, add_colors])Get an interactive help button from a list of fields.
get_hover_tool([mode, tooltips, attachment])Get the hover tool attribute.
get_title(title[, suffix, timestamp, location])Get a title including optional parameters.
get_tooltip_format([tooltips])Get a tooltip formatter from the tooltips attribute.
initialise_formatting(figure)Initialise default formatting for Bokeh figures.
plot_glacier_highlight(glacier_outlines)Highlight a glacier.
plot_region(shapefile, glacier_data, region_id)Plot a region with all its glaciers.
plot_region_with_glacier(shapefile, rgi_id)Plot a region with a highlighted glacier.
plot_shapefile(shapefile, **kwargs)Plot a shapefile.
plot_subregion(shapefile, glacier_data, ...)Plot a subregion with all its glaciers.
plot_subregion_with_glacier(shapefile, ...)Plot a subregion, its glaciers, and optional highlight.
set_defaults(updated_options)Set and overwrite default options for Bokeh figures.
set_formatting_kwargs(figure, **kwargs)Set kwargs for generic formatting.
set_hover_tool([mode])Set the hover tool attribute.
set_overlay_options(overlay, xlabel, ylabel, ...)Set plot options for Holoviews overlays.
set_tooltips(tooltips[, mode])Set the tooltips attribute and update the hover tool.
to_layout(overlay[, cols, sizing_mode, ...])Convert overlay to layout.
- check_holoviews()#
Check holoviews is installed to prevent silent failures.
- Raises:
ImportError – If Holoviews is not installed.
- Return type:
None
- decode_datacube(datacube)#
Get a dataset decoded into CF conventions.
This should be called after data processing to avoid changing the datacube’s metadata.
- Parameters:
datacube (GeoZarrHandler or xr.Dataset) – CryoTEMPO-EOLIS observations for elevation change.
- Returns:
Dataset decoded into CF conventions.
- Return type:
xr.Dataset
- get_all_palettes()#
Get all valid preset colour palettes.
These are custom presets and do not include those accessible via Bokeh or Holoviews.
These are:
brown_blue_pastel
brown_blue_vivid
hillshade_glacier
lines_jet_r
- Returns:
Preset colour palettes.
- Return type:
dict[tuple[str]]
- get_color_palette(name)#
Get a preset palette.
- Parameters:
name (str) – Name of palette.
- Returns:
Palette of hex colours.
- Return type:
list[str]
- Raises:
KeyError – If no matching palette is found.
- get_default_opts()#
Default options for Bokeh figures.
- Returns:
Default options for Bokeh figures. Not necessarily compatible with Holoviews or Geoviews objects.
- Return type:
dict
- get_help_button(
- text,
- position='right',
- add_colors=None,
Get an interactive help button from a list of fields.
- Parameters:
text (list[str]) – Help text.
position (str, default "right") – Help button position.
add_colors (hv.Cycle or None, default None) – Add coloured boxes next to text. Used for legend entries.
- Returns:
An interactive help button that displays text on hover and click.
- Return type:
bokeh.models.HelpButton
- get_hover_tool(
- mode='vline',
- tooltips=None,
- attachment='horizontal',
Get the hover tool attribute.
- Parameters:
mode (str, default "vline") – Hover mode for hover tool, e.g. “mouse”, “hline”, “vline”.
tooltips (list[tuple[str,str]], optional) – Hover tooltips.
attachment (str, default "horizontal") – Position of hover tooltip relative to cursor. Can be “horizontal”, “vertical”, “above”, or “below”.
- Returns:
Hover tool with tooltips and formatter.
- Return type:
bokeh.models.HoverTool
- get_title(
- title,
- suffix='',
- timestamp='',
- location='',
Get a title including optional parameters.
- Parameters:
title (str) – Title of figure.
suffix (str) – Comment appended to returned title. Default empty string.
timestamp (str or datetime.datetime, optional) – Timestamp. Default empty string.
location (str) – Location. Default empty string.
- Returns:
A title optionally including location, timestamp, and a suffix.
- Return type:
str
- get_tooltip_format(tooltips=None)#
Get a tooltip formatter from the tooltips attribute.
This ensures all tooltips with a format string (in curly braces) are formatted as fstrings. Skips tooltips without a format string.
- Parameters:
tooltips (list[tuple[str,str]], optional.) – List of Bokeh figure tooltips.
- Returns:
Tooltip field names with an associated “printf” or “datetime” value.
- Return type:
dict
- initialise_formatting(figure)#
Initialise default formatting for Bokeh figures.
Called separately from other plotting functions in this module to avoid overwriting on-the-fly formatting changes.
- Parameters:
figure (bokeh.plotting.figure) – An unformatted Bokeh plot.
- Returns:
Figure with default options applied.
- Return type:
bokeh.plotting.figure
- plot_glacier_highlight(glacier_outlines)[source]#
Highlight a glacier.
- Parameters:
glacier_outlines (gpd.GeoDataFrame) – Glacier geometry.
- Returns:
Glacier outline in white with black highlight.
- Return type:
hv.Overlay
- plot_region(
- shapefile,
- glacier_data,
- region_id,
Plot a region with all its glaciers.
- Parameters:
shapefile (geopandas.GeoDataFrame) – Glacier shapefile, which may contain more than one region.
glacier_data (geopandas.GeoDataFrame) – Glacier geometry for a glacier of interest.
region_id (int) – RGI region ID of the region of interest.
- Returns:
Interactive figure of all glaciers in a region.
- Return type:
hv.Overlay
- plot_region_with_glacier(
- shapefile,
- rgi_id,
- region_name='',
Plot a region with a highlighted glacier.
- Parameters:
shapefile (geopandas.GeoDataFrame) – Glacier outlines. This must be projected to EPSG:4326.
rgi_id (str) – RGI ID, converted to RGI60.
region_name (str, optional) – Name of region.
- Returns:
Map of region with glacier outlines.
- Return type:
hv.Overlay
- plot_shapefile(shapefile, **kwargs)#
Plot a shapefile.
- Parameters:
shapefile (geopandas.GeoDataFrame) – Must contain polygon geometry.
**kwargs – Extra arguments for plotting Polygons. View
gv.help(gv.Polygons)for all styling options.
- Return type:
Polygons
- plot_subregion(
- shapefile,
- glacier_data,
- subregion_name,
Plot a subregion with all its glaciers.
- Parameters:
shapefile (geopandas.GeoDataFrame) – Subregion shapefile.
glacier_data (geopandas.GeoDataFrame) – Glacier outlines.
subregion_name (str) – Name of subregion.
- Returns:
Interactive figure of all glaciers in a subregion.
- Return type:
hv.Overlay
- plot_subregion_with_glacier(
- shapefile,
- glacier_data,
- subregion_name,
- glacier_name='',
Plot a subregion, its glaciers, and optional highlight.
- Parameters:
shapefile (geopandas.GeoDataFrame) – Shapefile of all subregions.
glacier_data (geopandas.GeoDataFrame) – Glacier data.
subregion_name (str) – Name of subregion.
glacier_name (str, optional) – Name of glacier. If empty, no glacier is highlighted. Defaults to empty string.
- Returns:
Map of subregion with glacier outlines, and optionally a highlighted glacier.
- Return type:
hv.Overlay
- set_defaults(updated_options)#
Set and overwrite default options for Bokeh figures.
- Parameters:
updated_options (dict) – New key/value pairs which will overwrite the default options.
- Return type:
None
- set_formatting_kwargs(figure, **kwargs)#
Set kwargs for generic formatting.
Applies annotations, titles, labels.
- Parameters:
figure (bokeh.plotting.figure) – An unformatted Bokeh plot.
kwargs – Additional arguments passed to Bokeh figures.
- Returns:
Figure with default options applied.
- Return type:
bokeh.plotting.figure
- set_hover_tool(mode='vline')#
Set the hover tool attribute.
- Parameters:
mode (str, default "vline") – Hover mode for hover tool, e.g. “mouse”, “hline”, “vline”.
- set_overlay_options(
- overlay,
- xlabel,
- ylabel,
- title,
- aspect=2,
- legend_position='top_left',
- **kwargs,
Set plot options for Holoviews overlays.
- Parameters:
overlay (hv.Overlay) – Holoviews plot.
xlabel (str) – X-axis label.
ylabel (str) – Y-axis label.
title (str) – Plot title.
aspect (int, default 2) – Aspect ratio. Currently disabled due to several Holoviews bugs.
legend_position (str, default "top_left") – Location of legend box.
kwargs – Additional parameters passed to hv.Overlay objects.
- Returns:
Holoviews plot with updated options.
- Return type:
hv.Overlay
- set_tooltips(tooltips, mode='vline')#
Set the tooltips attribute and update the hover tool.
- Parameters:
tooltips (list[tuple[str,str]]) – List of Bokeh figure tooltips. The tooltips should only contain printf formatters.
mode (str, default "vline") – Hover mode for hover tool, e.g. “mouse”, “hline”, “vline”.
- Return type:
None
- to_layout(
- overlay,
- cols=1,
- sizing_mode='stretch_width',
- shared_axes=False,
- **kwargs,
Convert overlay to layout.
- Parameters:
overlay (list or hv.Overlay) – Either an Overlay object or a list of overlays.
cols (int, default 1) – Force the number of allowed columns in the layout.
sizing_mode (str, default "stretch_width".) – Layout responsiveness to screen dimensions.
shared_axes (bool, default False) – Whether the overlays should share data axes.
**kwargs – Extra arguments passed to hv.Layout options.
- Return type:
Layout
