Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to determine which villages lie upstream and which villages lie downstream big cities built on the side of rivers in Indonesia. I have the .shp file of villages and cities, the .shp file of all rivers in the country and some .tif files showing elevation (standard SRTM rasters, although I cannot find the exact resolution right now). I know how to identify villages located close to rivers (using spatial join with the rivers .shp file). However, I do not know how to determine the direction of the rivers. Should I discard my rivers .shp file and try to create a Digital Elevation Model from the SRTM .tif data? Using the .tif data I just did: FLOW DIRECTION + FLOW ACCUMULATION, but the computer is stuck since 40 minutes ago and even if it works I would not know how to continue..

Any suggestion? Thank you. /michele

share|improve this question
Welcome to our site, Michele! You may find some quick help by exploring the hydrology threads here. –  whuber Apr 22 '12 at 20:54
I believe you can distinguish the upstream and downstream endpoints of a river by comparing the elevations at both ends. The point with greater elevation should be upstream and vice/versa. I am cautiously optimistic that you could compare the elevations of the villages along a stream and rank them from most-upstream to most-downstream; however, with coarse SRTM data, I would also expect some false-positives using this approach. –  elrobis Apr 23 '12 at 0:03
@elrobis good idea. This should work. I would buffer the streams some distance and then clip your cities based on a single river. Then compare distances +- from your big cities. Indonesia has a lot of relief so 30m dtm should be sufficient. –  Thad Apr 23 '12 at 18:35
add comment

2 Answers

I would do this (relies on network analysis and PostGIS, but should be doable in ArcGIS, too):

  1. relocate the villages and cities to the closest point on the river network line (or create a temporary table for that). In PostGIS, the select query would be something like this:

    SELECT DISTINCT ON (v.gid) v.gid, v.village_id, ST_Line_Interpolate_Point(r.the_geom, ST_Line_Locate_Point(r.the_geom, v.the_geom)) as the_geom FROM rivers as r JOIN villages as v ON ST_DWithin(v.the_geom, r.the_geom, 0.5) ORDER BY v.gid, st_distance(v.the_geom, r.the_geom);

  2. cut your river network at those points (ST_Split() in PostGIS), thus modifiying the topology to include your villages and cities (important for routing).

  3. Now build your network. In PostGIS I would follow underdark's excellent guide at http://underdark.wordpress.com/2011/02/07/a-beginners-guide-to-pgrouting/, I am not sure how this works in ArcGIS though.

  4. Now identify the drain/mouth node(s) of your river network. That could be done either manually (since there are propably only a few ot them) or via a query like this (returns all points of your river network with only one edge - so they must be start/end points if your network - and with an altitude of less than 10 meters above sea level):

    SELECT * FROM (SELECT tmp.id as gid, tmp.count, node.the_geom FROM (SELECT id, count(*) FROM network JOIN node ON (start_id = id OR end_id = id) AND (end_id = id OR start_id = id) GROUP BY id ORDER BY id) as tmp JOIN node ON (tmp.id = node.id) WHERE tmp.count = 1 AND metres_above_sea_level < 10) as start_or_end;

  5. Finally, to determine which villages are below a city, you calculate the shortest path from your drains/mouths to this city (following the river upstream). Then, query for every village which intersects this path. There you have it. If you provide some sample data I could maybe do an implementation.
share|improve this answer
wow. thanks for the tips. To be honest the programming seems much more advanced than I expected (I am about to finish a phd in economics, and the use of GIS data in the field started only about 5 years ago, so courses are relatively basics). It would be great if you could try an implementation, so that I can study the procedure carefully. I posted some sample data here: mediafire.com/?9px7t1s699dct3i If it works I will surely acknowledge you and the website in the thesis! –  Michele Apr 23 '12 at 13:32
that is, mediafire.com/?9px7t1s699dct3i –  Michele Apr 23 '12 at 13:33
OK. I see that the villages in your file are not point features but rather patches of land (village areas) which are sometimes cut through by more than one river. How do you determine the "correct" river of the village (I assume this would be the river the actual village buildings are next, so maybe land use satellite imagery could be used)? –  chriserik Apr 24 '12 at 10:27
thanks! I was thinking to go a bit rough at this stage and exclude villages which are cut from more than one river. This may make the statistical analysis late more imprecise, but I don't think it will bias it. At the moment these village data are the best I can get (and I am already lucky to have these I suspect). –  Michele Apr 24 '12 at 14:17
Hi @Michele, sorry for the long wait, i had to finish a thesis myself... I have looked further into the dataset, and i'm afraid only a few of the village areas are cut by only one river. In my opinion, if there is no possibility to refine the data, a statistical analysis is useless (even though I too am impressed that there is such data available after all!) –  chriserik May 3 '12 at 22:23
add comment

@chriserik: thanks for trying, very appreciated. At the moment the river polylines are a bunch of segments divided (most of the times) by nodes. In order to intersect correctly the river polylines with the village polygons I think that the river data should have one observation for each river (rather than segment): typically the river would start at the top of a mountain and would end in the sea/ocean. I think that the share of villages intersected by more than one river would be much lower than the share of villages intersected by more than one segment. I tried to do this by dissolving the segments by one of the two node identifiers (tnode and fnode in the attribute table). Things improved, but I definitely did not manage to get only one observation for each river (I suspect the data must be also expanded somehow and not just dissolved). This is why I left the raw data in the sample and you may have had the impression that most of the villages are cut by many rivers. I guess that I need to find a good summer school in hydrology (or an hydrology co-author) to come out of this issue.

@elrobis/@thad: your tips s as well. They require the same preliminary work though, so I

share|improve this answer
@elrobis/@thad: your tips require the same preliminary work, so I cannot use them at the moment. Thank you very much though. –  Michele May 15 '12 at 9:17
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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