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

2014-11-14 Thread Glynn Clements
Moritz Lennert wrote: r.mapcalc down_id = if(dir=1, id[1,1], if(dir=2, id[0,1], if(dir=3, id[-1,1] etc r.mapcalc follows C expression syntax; =is assignment, == is the equality test. -- Glynn Clements gl...@gclements.plus.com ___ grass-user

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

2014-11-14 Thread Rainer M Krug
Glynn Clements gl...@gclements.plus.com writes: Moritz Lennert wrote: r.mapcalc down_id = if(dir=1, id[1,1], if(dir=2, id[0,1], if(dir=3, id[-1,1] etc r.mapcalc follows C expression syntax; =is assignment, == is the equality test. In this case shouldn't it be , | r.mapcalc

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

2014-11-14 Thread Moritz Lennert
On 14/11/14 11:21, Rainer M Krug wrote: Glynn Clements gl...@gclements.plus.com writes: Moritz Lennert wrote: r.mapcalc down_id = if(dir=1, id[1,1], if(dir=2, id[0,1], if(dir=3, id[-1,1] etc r.mapcalc follows C expression syntax; =is assignment, == is the equality test. In this case

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

2014-11-14 Thread Thomas Adams
Glynn Rainer, YES, absolutely -- I caught that and made it '==' instead of '='. When typing quickly, I sometimes make that mistake and then have to correct myself. But fundamentally, Moritz' approach worked very well and produced what I needed. I have a more difficult problem now, something I

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

2014-11-13 Thread Moritz Lennert
On 13/11/14 00:25, Thomas Adams wrote: Moritz, I need to be sure I understand this line: down_id = if(dir=1, id[1,1], if(dir=2, id[0,1], if(dir=3, id[-1,1] etc dir=1 is what direction?; dir=2 is what direction?, etc. Is dir=1 directly to the 'East', dir=3 directly 'south', dir=5 directly

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

2014-11-12 Thread Rainer M Krug
Thomas Adams tea...@gmail.com writes: All: 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: (1) a unique integer identifier (1 -- N) for the pixel (2) the integer

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

2014-11-12 Thread Thomas Adams
Rainer, Thank you very much. I just downloaded everything via git. I greatly appreciate your help. Best, Tom On Wed, Nov 12, 2014 at 1:28 AM, Rainer M Krug rai...@krugs.de wrote: Thomas Adams tea...@gmail.com writes: All: I need to generate an ascii text file from a flow direction grid

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

2014-11-12 Thread Moritz Lennert
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

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

2014-11-12 Thread Thomas Adams
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

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

2014-11-12 Thread Johannes Radinger
Hi Tom, what comes into my mind is following approach (not tested): 1) calculate flow direction using r.watershed for each pixel of your map 2) transforming raster to vector points (r.to.vect), adding some columns for your results (X, Y, ID). This step should provide you already with unique IDs

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

2014-11-12 Thread Thomas Adams
Moritz, I need to be sure I understand this line: down_id = if(dir=1, id[1,1], if(dir=2, id[0,1], if(dir=3, id[-1,1] etc dir=1 is what direction?; dir=2 is what direction?, etc. Is dir=1 directly to the 'East', dir=3 directly 'south', dir=5 directly 'west' and dir=7 directly 'north' Also,

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

2014-11-11 Thread Thomas Adams
All: 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: (1) a unique integer identifier (1 -- N) for the pixel (2) the integer identifier of the downstream pixel (assuming there is