I'm working with shapefiles representing rivers (rivers.shp), and DEM for the terrain elevation (terrain.tif).

Basically, I want to check that my rivers (stored as polylines in my shapefile) behave like "natural" water flow, meaning that it mainly go downstream, can not go uphill first and downhill then, etc...

I'm using GDAL/OGR in Python, and don't really see how to proceed. Should I extract the points of the polylines in the shp? Look for the elevation at those points in the DEM, and then compute my decision?


  • 2
    Unless the polylines were derived from the DEM or the DEM was created using those polylines, there are certain to be such discrepancies. What actions will you take when you find them? Do you plan to change the DEM, change the polylines, both, or neither? This partially determines good ways to make the comparisons. BTW, some potential solution methods are given in answers at gis.stackexchange.com/questions/8685/…. – whuber Apr 24 '13 at 14:46
  • Polylines reprensenting the rivers are not necessarily derived from the elevation. Sometimes rivers may be computed from the elevation, but I will deal with all cases. I don't need to change the polylines, just give an answer to the user (i.e. nb of wrong polylines). You'd say feasible in GDAL/OGR Python? – eouti Apr 24 '13 at 17:41
  • 2
    I agree w/ @whuber, that if the watercourses were derived from different data (i.e. different resolution DEM such as 90, 30, 10-meter, or traced by a person looking at an aerial image), you'll have to run it through several programmatic filters (like snapping in-stream points to the lowest-elevation grid cells given an established radius?) to even be close to a fair comparison. ..and if your rivers data has been simplified, you can expect little, if any, agreement between the data. – elrobis Apr 24 '13 at 19:18

I'm not surprised that you haven't got an answer to this seemingly simple question yet. You've opened a whole can of worms here! Take this DEM and vector streams layer as an example:

enter image description here

At the simplest level, you could always perform a profile analysis with your streams and see whether they have predominantly downward profiles:

enter image description here

Consider for a moment what we are actually comparing though. We are comparing a mapped vector stream network, probably mapped off of aerial photographs or from similar techniques, to the elevations contain in a DEM; both of these things are types of models and are not necessarily related to the 'true stream' that exists in the real world. The mapped stream, for example is likely less accurate in the smaller headwater tributaries than it is in the higher order streams. Network extent is one of the least accurate aspects of the mapped stream. And if you think about it, how do you even define the real world stream? As you move towards the channel head, it's likely that the stream becomes intermittent or ephemeral; how often does a stream need to flow to be considered a stream? How well defined and continuous does a channel need to be before we consider it to be a stream? Yikes, those are hard questions to answer. Any way you look at it though, we should expect the mapped stream network and the 'digital stream' implicit in the surface flowpath data contained in the DEM to deviate from one another to some degree.

Nonetheless, we could compare the mapped stream with the 'digital stream' contained in the DEM by examining how the flowpaths issuing from the points of our mapped channel heads differ with the mapped pathway:

enter image description here

Now, these modelled flowpaths are going to depend on the particular flow algorithm used to simulate flow over the DEM and on the DEM quality, source and resolution. Importantly, however, these flowpaths will be monotonically descending paths (always decreasing elevations) unlike the mapped streams.

enter image description here

So what do you do where the two paths deviate? A common approach to handle this problem is to actually 'burn' the the mapped stream into the DEM by lowering the elevations coincident with the vector polylines. This is probably an okay approach when the mapped streams are of much higher quality than the DEM (although I'm still not keen on the approach because it'll mess with elevations and slopes) but it is a terrible approach if your DEM is of higher quality, e.g. most LiDAR DEMs contain more accurate surface flowpaths than the available blue lines on topographic maps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.