Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
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
    
Thanks for your help –  teamAngat Feb 19 '11 at 16:44

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.

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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