Closed MunsakaPKM closed 9 months ago
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.
Hello! Thank you so much - it worked, although the issue was not related to loading the network. I was not aware that the interactive leaflet network was being created in the background and saved on my machine. However, it was not displaying on its own. I'm not sure if this is something that is to be expected, or if there is a problem with my code.
On Mon, Feb 12, 2024 at 8:08 PM Kirk Bonney @.***> wrote:
HI @MunsakaPKM https://github.com/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.
— Reply to this email directly, view it on GitHub https://github.com/USEPA/WNTR/issues/404#issuecomment-1939271681, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEHWEYWJUC3VTWCBWO7AHFLYTJLC7AVCNFSM6AAAAABCYV447OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZZGI3TCNRYGE . You are receiving this because you were mentioned.Message ID: @.***>
@MunsakaPKM, glad you were able to resolve the issue. Saving is the expected behavior.
I get it, thanks a lot!
On Wed, Feb 14, 2024, 21:19 Kirk Bonney @.***> wrote:
@MunsakaPKM https://github.com/MunsakaPKM, that is the expected behavior.
— Reply to this email directly, view it on GitHub https://github.com/USEPA/WNTR/issues/404#issuecomment-1944445906, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEHWEYW5RIJJQCO5SYW3U43YTUE5VAVCNFSM6AAAAABCYV447OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBUGQ2DKOJQGY . You are receiving this because you were mentioned.Message ID: @.***>
Good Day,
I wanted to bring to your attention an observation I made regarding the module network.py in the WNTR library. Specifically, I noticed that the location specifications for the function “plot_leaflet_network” are in the format [longitude, latitude], which appears to swap the longitude and latitude values for some different coordinate systems. For instance, in line 556:
m = folium.Map(location=[center.iloc[1], center.iloc[0]], zoom_start=zoom_start, tiles='cartodbpositron')
Upon further testing using different known locations, I discovered that this approach does work with the example location provided in the documentation, but it leads to some unexpected results in the generated HTML file with other locations. In some cases, the map does not display the actual location or, at times, it does not display anything at all. For example, when using the city of Mutare, with a latitude of -18.9667 and a longitude of 32.6667, or London [51.5074, -0.1278], the map fails to appear.
However, I found that by reformatting the location specification to [center.iloc[0], center.iloc[1]], the map is displayed correctly but the network disappears unless a similar adjustment is made in line 592 for Nodes locations and lines 611 & 612 for Links (start_loc & end_loc locations), then everything works well.
Apologies if this behavior is something that is a result of any error I might have made without realizing. However, after careful examination, I am confident that the observed discrepancy in the code is not due to any mistake on my part. I wanted to bring it to your attention and hear from you.
The above applies to the part about “Interactive leaflet networks” in the section “‘Graphics’ of the documentation:
wn = wntr.network.WaterNetworkModel('Net3.inp')
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')
I appreciate your time and efforts in maintaining and improving the WNTR library.
Best regards,
Prince K. Munsaka
On Thu, Feb 15, 2024 at 5:51 PM Katherine Klise @.***> wrote:
Closed #404 https://github.com/USEPA/WNTR/issues/404 as completed.
— Reply to this email directly, view it on GitHub https://github.com/USEPA/WNTR/issues/404#event-11817447727, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEHWEYW6HHUHE5Q2IYXEJW3YTYVG7AVCNFSM6AAAAABCYV447OVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRHAYTONBUG43TENY . You are receiving this because you were mentioned.Message ID: @.***>
@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.
Thank you so much! I am happy to report that both of the options you suggested have proven to be successful I appreciate your support
On Fri, Feb 16, 2024 at 4:41 PM Kirk Bonney @.***> wrote:
@MunsakaPKM https://github.com/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.
— Reply to this email directly, view it on GitHub https://github.com/USEPA/WNTR/issues/404#issuecomment-1948506978, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEHWEYWVJMTDSQJPL2HG6FDYT5V2RAVCNFSM6AAAAABCYV447OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBYGUYDMOJXHA . You are receiving this because you were mentioned.Message ID: @.***>
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.