import sys
sys.path.append('../py')
from hydromap import Flow
from delineate import delineate
import pandas as pd
from ipyleaflet import Map, Marker
import ipywidgets as widgets
from IPython.display import display
#from sidecar import Sidecar
center = (-10, -60)
zoom = 4
m = Map(center=center, zoom=zoom, interpolation='nearest')
#sc = Sidecar(title='Map')
#with sc:
# display(m)
m
message = widgets.Label()
display(message)
flow = Flow(m, message)
widgets.interact(flow.show, width=widgets.FloatSlider(min=3/1200,max=0.1,step=1/1200,value=0.05))
m.on_interaction(flow.show)
A menu pops up when you right-click on a location. It allows you to:
Use the following cell to display a marker on the map at a particular location. You can then drag it with the mouse and get its new location back with the next cell.
latlon = -0.6672326905216578, -51.08033180236817 # Amazon outlet
marker = Marker(location=latlon)
m.add_layer(marker)
marker.location
m.remove_layer(marker)
If you set a marker with the menu, you can get its position back:
flow.marker.location
The following not only delineates the Amazon basin, but it creates a hydrologic partition, including the subbasins whose outlet has a virtual station. The whole thing takes days to compute, but the result has been stored in pangeo-data/ws_mask/amazonas
Google Cloud Storage bucket.
df = pd.read_pickle('amazonas.pkl')
sub_latlon = df[['new_lat', 'new_lon']].dropna().values
lat, lon = -0.6672326905216578, -51.08033180236817 # Amazon outlet
delineate(lat, lon, sub_latlon, acc_delta=1_000_000, progress=True)