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 this shell script:

#!/bin/sh
r.mapcalc water = 120
d.rast water
i=1
while [ $i != 100 ]
do
    n=1
    while [ $n != 10 ]
        do
            r.mapcalc < water.mapcalc
            d.rast water
            n='expr $n + 1'
        done
        g.copy rast=water,water.$i
        i = 'expr $i + 1'
    done

It is from http://grass.osgeo.org/gdp/raster/mapcalc-algebra.pdf. I understand the syntax of the code since I am a programmer, but I cannot understand the line r.mapcalc < water.mapcalc. What does it mean? Sorry first time to use a shell script.

share|improve this question
add comment

1 Answer

It's input redirection -- just like you can redirect the output of a command into a file,:

command > outfile.txt

you can redirect the input from a file:

command < infile.txt

This is the same as:

cat infile.txt | command

Hopefully helpful!

share|improve this answer
    
I do not know if I understood it correctly. Does it mean that the output of the water.mapcalc is "redirected" to the command r.mapcalc? But, what does the command r.mapcalc compute? Isn't it that the r.mapcalc command needs additional parameters in order to work (map name and value)? I'm trying to make the Hydrologic Simulation in grass.osgeo.org/gdp/raster/mapcalc-algebra.pdf work. Thanks –  teamAngat Feb 21 '11 at 13:33
    
grass.fbk.eu/gdp/html_grass64/r.mapcalc.html should help. r.mapcalc is general purpose map algebra, and it will compute whatever the contents of the 'water.mapcalc' file tells it to compute. –  Dan S. Feb 21 '11 at 21:50
add comment

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.