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)
fig, ax = plt.subplots()
_= dem.plot(ax=ax,cmap="terrain")
_= s2.plot(ax=ax,color='k')
plt.show()
