USEPA/WNTR

Generating Interactive leaflet networks

MunsakaPKM opened this issue · 7 comments

I am struggling with generating leaflet networks, I guess it requires some certain knowledge about folium and UTM that i don't have or maybe a certain environment for running the code. How can I generate this using desktop compiler, I am aware of the example given in the documentation(Graphics) but it is not working for me because I am failing to complete it and make it run. Please help, thank you !

Example

longlat_map = {'Lake':(-106.6851, 35.1344), '219': (-106.5073, 35.0713)}
wn2 = wntr.morph.convert_node_coordinates_to_longlat(wn, longlat_map)
length = wn2.query_link_attribute('length')
wntr.graphics.plot_leaflet_network(wn2, link_attribute=length, link_width=3,
... link_range=[0,1000], filename='length.html')

Environment
[Optional] Provide information on your computing environment.

  • Operating system: 10
  • Python version: 3.11
  • WNTR version: Current version

HI @MunsakaPKM, it looks like you need to load in the water network first before running the code you shared.
Try running this line first:
wn = wntr.network.WaterNetworkModel('networks/Net3.inp')

If that doesn't solve your issue, please share the error you are seeing on your end.

@MunsakaPKM, glad you were able to resolve the issue. Saving is the expected behavior.

@MunsakaPKM, I suspect that this issue has to do with the ordering of the coordinates. WNTR uses (long, lat) as opposed to (lat, long). You can use the convert_node_coordinates_to_longlat to perform this conversion for you. Alternatively, if your coordinates are already in (lat, long) you can just write a for loop that swaps the ordering manually.