2

I have created a map with the flow directions using the d.rast.arrow. Can i query on the map to know where the direction of the arrows are? I am going to use the arrow directions in an algorithm. Or, is there a way to store the arrow directions in a text file so that I can import it in my code? Thanks!

1

The arrows directions are the Z value in the aspect map. The display (d.####) commands like d.rast.arrows only output to the display. You can export the aspect map as a text file, so you will have a file with coordinates and directiction of the flow.

  • The file that I exported using the r.out.xyz. Here is a sample row: "120.902916666667|14.99875|17.9524154663". Are all the values that are stored in the text file all values that are not null? – teamAngat Feb 15 '11 at 15:31
  • What? I didn't understand. – Pablo Feb 15 '11 at 16:02
  • Are the values stored in the text file generated by r.out.xyz all the values of the map that are not null? – teamAngat Feb 17 '11 at 15:37
  • Oh, yes, they are. As the manual say "This module will not export x,y coordinates for raster cells containing a NULL value". – Pablo Feb 17 '11 at 16:56
3

Why don't you just run your algorithm directly on the map you used to create the arrows? If it's an aspect map, it will already contain the direction in degrees counter-clockwise from east.

You can save the aspect map to a text file using r.out.ascii, e.g.

r.out.ascii input=aspectMap output=aspect.txt dp=2 null=*

where dp is the number of significant digits, and null is the character to be used in the ascii file when a value is not defined.

Depending on how you're implementing your algorithm, you can also do the calculations directly in GRASS using r.mapcalc. For example, to create a map that has the value 1 for all pixels with a north western aspect and 0 for all others, use

r.mapcalc "quadrant=if(aspect>90 && aspect <180,1,0)"

The mapcalc manual might be of interest to you.

  • Yes, I used an aspect map to display the arrows. How can I extract the directions from the aspect map? – teamAngat Feb 13 '11 at 15:27
  • Thanks! the mapcalc manual helped me a lot for the nested if. I might use and modify the Hydrologic Simulation of the paper to make my algorithm better. I will use D8 single flow direction for my rainfall simulation. – teamAngat Feb 15 '11 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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