plot_leaflet_network#

module wntr.graphics.network

plot_leaflet_network(wn, node_attribute=None, link_attribute=None, node_attribute_name='Value', link_attribute_name='Value', node_size=2, node_range=[None, None], node_cmap=['cornflowerblue', 'forestgreen', 'gold', 'firebrick'], node_cmap_bins='cut', node_labels=True, link_width=2, link_range=[None, None], link_cmap=['cornflowerblue', 'forestgreen', 'gold', 'firebrick'], link_cmap_bins='cut', link_labels=True, add_legend=False, round_ndigits=2, zoom_start=13, add_to_node_popup=None, add_to_link_popup=None, filename='leaflet_network.html')[source]#

Create an interactive scalable network graphic on a Leaflet map using folium.

Parameters:
  • wn (wntr WaterNetworkModel) – A WaterNetworkModel object

  • node_attribute (None, str, list, pd.Series, or dict, optional) –

    • If node_attribute is a string, then a node attribute dictionary is created using node_attribute = wn.query_node_attribute(str)

    • If node_attribute is a list, then each node in the list is given a value of 1.

    • If node_attribute is a pd.Series, then it should be in the format {nodeid: x} where nodeid is a string and x is a float.

    • If node_attribute is a dict, then it should be in the format {nodeid: x} where nodeid is a string and x is a float

  • link_attribute (None, str, list, pd.Series, or dict, optional) –

    • If link_attribute is a string, then a link attribute dictionary is created using edge_attribute = wn.query_link_attribute(str)

    • If link_attribute is a list, then each link in the list is given a value of 1.

    • If link_attribute is a pd.Series, then it should be in the format {linkid: x} where linkid is a string and x is a float.

    • If link_attribute is a dict, then it should be in the format {linkid: x} where linkid is a string and x is a float.

  • node_attribute_name (str, optional) – The node attribute name, which is used in the node popup and node legend

  • link_attribute_name (str, optional) – The link attribute name, which is used in the link popup and link legend

  • node_size (int, optional) – Node size

  • node_range (list, optional) – Node range ([None,None] indicates autoscale)

  • node_cmap (list of color names, optional) – Node colors

  • node_cmap_bins (string, optional) – Node color bins, ‘cut’ or ‘qcut’

  • node_labels (bool, optional) – If True, the graph will include each node labelled with its name.

  • link_width (int, optional) – Link width

  • link_range (list, optional) – Link range ([None,None] indicates autoscale)

  • link_cmap (list of color names, optional) – Link colors

  • link_cmap_bins (string, optional) – Link color bins, ‘cut’ or ‘qcut’

  • link_labels (bool, optional) – If True, the graph will include each link labelled with its name.

  • add_legend (bool, optional) – Add a legend to the map

  • round_ndigits (int, optional) – Rounds digits in the popup

  • zoom_start (int, optional) – Zoom start used to set initial scale of the map

  • add_to_node_popup (None or pd.DataFrame, optional) – To add additional information to the node popup, use a DataFrame with node name as index and attributes as values. Column names will be added to the popup along with each value for a given node.

  • add_to_link_popup (None or pd.DataFrame, optional) – To add additional information to the link popup, use a DataFrame with link name as index and attributes as values. Column names will be added to the popup along with each value for a given link.

  • filename (str, optional) – Filename used to save the map