import topotoolbox
import matplotlib.pyplot as plt
dem = topotoolbox.load_dem('bigtujunga')
fd = topotoolbox.FlowObject(dem)
s = topotoolbox.StreamObject(fd)
s = s.klargestconncomps(1)
z = topotoolbox.imposemin(s, dem)
kp = s.knickpointfinder(z, tolerance=50.0)
d = s.upstream_distance()
fig,ax = plt.subplots()
_= s.plotdz(dem, ax=ax, color='k')
_= ax.scatter(d[kp], z[kp])
_= ax.autoscale_view()
plt.show()
