import topotoolbox
import matplotlib.pyplot as plt
dem = topotoolbox.load_dem('perfectworld')
fd = topotoolbox.FlowObject(dem)
s = topotoolbox.StreamObject(fd,threshold=1000,units='pixels')
s2 = s.klargestconncomps(1)
st = s2.trunk()
fig,ax = plt.subplots()
_= dem.plot(ax=ax,cmap="terrain")
_= s.plot(ax=ax, color='r')
_= s2.plot(ax=ax,color='k')
_= st.plot(ax=ax, color='b')
plt.show()
