Plotting colored stream networks

Posted on Updated on

Visual exploration of stream networks and channel length profiles is a mandatory first step before advancing towards more sophisticated tools such as slope-area plots or chiplots. Taking a look at both planform river patterns and respective channel length profiles will provide a good impression of the three-dimensional river patterns. Here is a quick guide how to visualize a stream network using different colors for each river system (or drainage basin). An underappreciated function comes in handy here: STREAMobj2cell.

DEM = GRIDobj('srtm_bigtujunga30m_utm11.tif');
FD  = FLOWobj(DEM,'preprocess','carve');
S   = STREAMobj(FD,'minarea',1000);
CS  = STREAMobj2cell(S);

h1 = subplot(1,2,1);
hold(h1,'on');
h2 = subplot(1,2,2);
hold(h2,'on');
clrs = jet(32);

for r=1:numel(CS);
axes(h1)
plot(CS{r},'color',clrs(r,:));
axes(h2)
plotdz(CS{r},DEM,'color',clrs(r,:));
end;
hold(h1,'off')
hold(h2,'off')

axis(h1,'image')
box(h1,'on')
axis(h2,'image')
set(h2,'DataAspectRatio',[1 1/16 1])
box(h2,'on')

streamcoloring

I have manually edited the figure to make the figure look nicer. The question, however, is: What is the function STREAMobj2cell doing? This function returns stream networks belonging to an individual drainage basin as separate STREAMobjs in a cell array. Having this cell array, you just need to loop through and index into the cell array to access individual “connected components” of the stream network. Together with other functions for stream network modification such as modify, trunk or klargestconncomps, I think STREAMobj2cell will greatly help you to automate your stream network analysis.

Advertisements

2 thoughts on “Plotting colored stream networks

    simr87 said:
    June 9, 2017 at 8:25 am

    How can I convert this graph in a excel or csv tab?

      wschwanghart responded:
      June 9, 2017 at 9:29 am

      Hi. You can’t convert the graph, but I guess you may want to export the data in some tabular format. This can be done with the function STREAMobj2XY which has some nice additional functionality. For example you could do the following to export a table with X, Y, Z and distance
      t = table;
      d = S.distance;
      [t.X,t.Y,t.Z,t.distance] = STREAMobj2XY(S,DEM,d);
      writetable(t,’filename.xlsx’)

      Hope this helps,
      Wolfgang

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s