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);
h2 = subplot(1,2,2);
clrs = jet(32);

for r=1:numel(CS);

set(h2,'DataAspectRatio',[1 1/16 1])


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.


Media coverage of our research in Nepal

Posted on Updated on

One of the current projects of Geohazards group at University of Potsdam is about the young geologic history of the Pokhara basin in Nepal.

In the future, I’ll post some more information on our work there. This post is just a quick reference to a two-part movie (in german) produced by the RBB and which was shown on 08. and 15. December 2014 (part one, part two). The movie mainly covers the research project on airborne acquisition of meteorological and image data undertaken by the RWTH Aachen and the German Space Agency (DLR). At around 36 min of the second part, you’ll see Oliver Korup and me eagerly anticipating the use of this data in our research.

New paper out in Geomorphology

Posted on Updated on

The mathematical branch that deals with networks is called graph theory. No wonder, that TopoToolbox that deals with river and flow networks has strong relations to graph theory. Indeed, many computational tricks adopted in TopoToolbox to increase the speed of deriving flow related terrain attributes (e.g. flow accumulation) are rooted in graph theoretic algorithms such as topological sorting. Yet, there is much more to learn from graph theory for diverse applications in geomorphology. Tobias Heckmann, me and Jonathan D. Phillips have written a review paper about these applications, and the manuscript has just now been accepted by the journal Geomorphology. The manuscript reviews all sorts of graph theory applications in geomorphology including the analysis of system structures and the analysis of spatially explicit networks. Have fun reading. If you don’t have access to the journal, I am happy to send you a pdf-copy.

Heckmann, T., Schwanghart, W., Phillips, J.D. (2014): Graph theory – recent developments of its application in geomorphology. Geomorphology, accepted. [DOI: 10.1016/j.geomorph.2014.12.024]


Distances in drainage basins

Posted on Updated on

What is the location in a catchment being farthest away from the catchment outlet? Clearly, there are several answers to this question. It depends on which distance metric you use. So which metrics might be relevant?

Let’s prepare the data first and load the example DEM, calculate flow directions (FLOWobj), and derive a stream network (STREAMobj) by thresholding upslope area. We extract the largest subgraph of the network (klargestconncomps) and retrieve its outlet pixel (streampoi). We derive the outlet’s coordinates using ind2coord and calculate the drainage basin of this outlet (drainagebasins).

DEM = GRIDobj('srtm_bigtujunga30m_utm11.tif');
FD = FLOWobj(DEM,'preprocess','carve');
S  = STREAMobj(FD,'minarea',1000);
S  = klargestconncomps(S,1);
ix = streampoi(S,'outlets','ix');
[xout,yout] = ind2coord(DEM,ix);
DB  = drainagebasins(FD,ix);
DB  = DB>0;

As a first measure of distance, you might take the largest euclidean distance within the catchment. Given a catchment outlet ix and its drainage basin, you can calculate this as follows: Use bwdist to do calculate the distance seeded at the catchment outlet. Note that this function is not (yet) overloaded in TopoToolbox. Thus, access to GRIDobjs properties is required. Here is my approach to do this:

% Create a logical seed grid
SEED = GRIDobj(DEM,'logical');
SEED.Z(ix) = true;
% and an empty grid to which we'll write the output of bwdist
D    = GRIDobj(DEM);
D.Z  = bwdist(SEED.Z,'euclidean') * DEM.cellsize;

maxd = max(D.Z(DB.Z(:)));
LOCS = D==maxd & DB;
IX   = find(LOCS.Z);
[x,y] = ind2coord(DEM,IX);

hold on
plot([repmat(xout,size(x)) x]',[repmat(yout,size(y)) y]','k');
hold off


If the drainage basin has a curved shape, however, one might want to constrain distance calculation to a path that runs inside the catchment. This would better represent the true distance when the centerline of the drainage basin is to be approximated by a straight line. This is where bwdistgeodesic comes in:

D.Z = bwdistgeodesic(DB.Z>0,SEED.Z,'q') * DEM.cellsize;
maxd = max(D.Z(DB.Z(:)));
LOCS = D==maxd & DB;
IX   = find(LOCS.Z);
[x,y] = ind2coord(DEM,IX);
hold on
plot([repmat(xout,size(x)) x]',[repmat(yout,size(y)) y]','k');
hold off


In our case, there is no difference between the outputs of bwdist and bwdistgeodesic since the shortest path runs within the mask set by the drainage basin.

In other instances, you might want to derive the farthest distance that a raindrop must take to reach the outlet. This distance refers to the longest distance along the flow network which can be calculated with the TopoToolbox function flowdistance. For comparison, we will plot the longest flowpath(s), too.

D  = flowdistance(FD,ix);
maxd = max(D.Z(DB.Z(:)));
LOCS = D==maxd & DB>0;
IX   = find(LOCS.Z);
[x,y] = ind2coord(DEM,IX);
hold on
plot([repmat(xout,size(x)) x]',[repmat(yout,size(y)) y]','k');
I = influencemap(FD,IX);
S2 = STREAMobj(FD,I);
hold off


Note that flowdistance takes additional parameters that let you define seed pixels other than the outlet pixels. You might, for example, calculate the flow distances upstream of the stream network.

D = flowdistance(FD,S);


In other instance you might want to know at each location the longest flowpath lengths. I use the function dilate here to highlight high distance values as they prevail along the stream network.

D = flowdistance(FD,'downstream');
D = dilate(D,ones(5));


Do you have applications for distance metrics in drainage basin analysis. Let me know and leave a comment.

— edited on 14 August 2015 to remove formatting errors —

New EGU Geomorphology blog

Posted on

The Geomorphology section of the EGU is now blogging! With Sabine Kraushaar and Jan Blöthe being editors, I am pretty sure that this will be a lively blog worth following. Enjoy the latest announcements on workshops, conferences, techniques and everything else related to geomorphology here.

Report bugs!

Posted on Updated on

You’ll rarely find software without bugs. The same holds true for TopoToolbox. While Dirk and I were very careful to avoid bugs by using error checking and input argument parsing, amongst other, some bugs made it to the finally published version 2. One such bug happened to be an error message issued when calling functions that use inputParser. In various instances we called the function with a capital i (InputParser), which did not issue an error for our MATLAB version at the time we were developing the code. However, MATLAB apparently became more case-sensitive in later versions. All of these bugs should be removed in the latest version of TopoToolbox found in the trunk directory.

Still, there are some more functions that contain bugs. One super-buggy function is preprocessapp which I want to update since long.

Now that MATLAB 2014b has been released, we are awaiting some new bugs to appear. The Mathworks has introduced some fundamental changes to MATLAB’s graphics system which may be incompatible with our code. Correcting for these compatibility issues is tedious since we want to keep our code clean while retaining it compatible with older versions. We are very much aware that not everyone has MATLAB (yes, it’s expensive) nor its latest version.

How can you help us? Report bugs here (use the comments)! Let us know about problems that you face with our code. We know how frustrating it is to work with buggy code.

New paper out in Natural Hazards and Earth System Sciences Discussions

Posted on Updated on

Roads are the arteries of societies. Landslides, flooding, and earthquakes may frequently damage roads, disrupt traffic flow and curtail the functioning of the road network. Where landslides damage roads, these may become impassable and drivers must detour these locations. The duration of blockage and the length of a detour route (extra time and fuel) determine largely the costs to get from one location to another. In the study by Meyer et al., we used existing data on road blocking debris flows, trigger probabilities and vehicle counts to investigate the impact of debris flows on traffic flow in Southern Norway. We used graph theory to emulate a traffic navigation system that finds the shortest detour route if a road section is blocked. This allowed us to determine road sections that are both susceptible to debris flows and that are central to the functioning of Norway’s road network. With only few roads connecting Norway’s capital Oslo and cities such as Bergen and Trondheim on the western coast, the sparse road network through the central highlands (e.g., Hardanger Vidda, Jotunheimen, Sogne Fjell) is particularly worth to look at. We find that detour routes connecting two adjacent junctions may be very long so that individual and local traffic costs can be high if eminent road sections are disrupted. Regional traffic may remain often largely unaffected by individual road blockages, as long as a good and timely information system exists that warns and reroutes travellers. Spatial clustering of debris flow events during extreme rainfalls with large spatial extent, however, may significantly increase detour routes even for regional traffic.

Meyer, N.K., Schwanghart, W., Korup, O., Nadim, F. (2014): Roads at risk – traffic detours from debris flows in southern Norway. Nat. Hazards Earth Syst. Sci. Discuss., 2, 6623-6651. [DOI: 10.5194/nhessd-2-6623-2014]