0

I am running a loop from a shell script in GRASS GIS 7. Basically, values are subtracted from a raster in each step. I want the script to stop/exit if any of the raster values is 0 or less. Is there a simple if(,,) command to accomplish this?

2 Answers 2

0

Don't know which shell language you are using but basically I'd use r.info -r inside an if block to get the value range for the raster. If you find that your raster has values 0 or less, you the use break or continue depending on your need, to exit the loop and carry on.

Break and Continue manual page of bash.

http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_05.html

0

Thanks! Solved it: I added a if-crierion. If below 0, then 1, else 0. In each step I have Octave (runs in the background via executable) calculate the sum of the raster values. Shell/GRASS reads the value: while [ $X -lt 1 ] do [...]

as soon as sum >=1, the loop stops.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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