r.watershed mods

Charles Ehlschlaeger chuck at rap.NCGIA.UCSB.EDU
Thu Jan 12 21:28:20 EST 1995


James,

>For each cell in an accumulation map, my client wants to know how much
>came from each landuse in the watershed.  Say we have 3 landuses: A,
>B, C. Then in r.mapcalc parlance,
>    accumulation_map=A+B+C
>Has anyone done something like this? It would require adding
>an additional command line option (landuse=) and would create more
>(potentially a large number of) output files (depending upon
>how many landuses are present).

A simple shell script could do the job.  
Assuming the landuse map has categories from 1 to 10, the script would be:
***********cut here******************
#!/bin/csh -f

set i = 1
while ( $i < 11 )
  r.mapcalc "Category$i = if( landuse == $i)"
  r.watershed elev=dem.name flow=Category$i accumulation=Accum$i
  @ i++
end

END:
***********cut here******************
You will end up with 10 maps: Accum1, Accum2,...,Accum10 where each cell 
contains the number of cells upstream and including that cell for that
category.  Add a few bells and whisles, you got yourself a program.

BTW, the 3.1+ interactive version of r.watershed can collect basin statistics
based on the threshold size for any number of categorical or continuous
maps, but the output is ASCII text.  I'm not sure that version still exists.
_________________________________________________________________________
Charles Ehlschlaeger                         e-mail  : chuck at geog.ucsb.edu
Nat. Centr for Geographic Information and Analysis
3510 Phelps Hall                             Phone   : 805-893-8652
University of California                     Fax     : 805-893-8617
Santa Barbara, CA 93106 

The Information Superhighway is really an acronym for:

"Interactive Network For Organizing, Retrieving, Manipulating, Accessing, 
 And Transferring Information On National Systems, Unleasing Practically
 Every Rebellious Human Intelligence, Gratifying Hackers, Wiseacres, And
 Yahoos."
_________________________________________________________________________



More information about the grass-dev mailing list