[GRASS-user] A question before I embark on a programming exercise

Thomas Adams tea3rd at gmail.com
Wed Nov 12 06:39:27 PST 2014


Awesome, Moritz!

Thank you so much...

Tom

On Wed, Nov 12, 2014 at 7:30 AM, Moritz Lennert <
mlennert at 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20141112/58a4f9e8/attachment-0001.html>


More information about the grass-user mailing list