Awesome, Moritz! Thank you so much...
Tom On Wed, Nov 12, 2014 at 7:30 AM, Moritz Lennert < mlenn...@club.worldonline.be> wrote: > On 12/11/14 05:10, Thomas Adams wrote: > >> I need to generate an ascii text file from a flow direction grid that >> consists of (among a couple other things that don't really matter at >> this point) for each pixel: >> > > Rainer has already given you a whole program, but here's a decomposition > in simple (untested) r.mapcalc steps: > > >> (1) a unique integer identifier (1 -- N) for the pixel >> > > r.mapcalc "id = row()*N + col()" # where N = nb cols * 10 > > (you might have to watch out for integer overflow, though) > > (2) the integer identifier of the downstream pixel (assuming there is >> ONLY one) >> > > Calculate flow direction in SFD mode and use something like this: > > r.mapcalc down_id = if(dir=1, id[1,1], if(dir=2, id[0,1], if(dir=3, > id[-1,1] .... etc > > > (3) the x,y location of the pixel (presumably, the lower left corner of >> the pixel) >> > > center of pixel: > r.mapcalc x = x() > r.mapcalc y = y() > > if you want the lower left corner: > > r.mapcalc x = x() - ewres()/2 > r.mapcalc y = y() - nsres()/2 > > > Then export everything with > > r.stats -1 in=id,x,y,down_id > > Moritz >
_______________________________________________ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user