non-interactive r.mask (v. 4.2.1)

Justin Hickey jhickey at
Thu Jul 15 18:14:59 EDT 1999

Hi Stephan

On Thu, 15 Jul 1999, Stephan Eickschen wrote:

> Hi GRASSers,
> I have to do some stupid work - so I would rather enjoy to write a skript,
> fire it and have a decent cup of tea :) But, unfortunatly, I don´t know the
> right, best, or "state-of-the-art" way.
> My problem:
> I have many raster data sets which have to be processed in the same way.
> That would not be too complicated if I do not have to change between
> different MASKs. A possibility would be to write the skript without
> automating the MASK setting. Then I would have to
> - set MASK no. 1
> - fire the skript
> - set MASK no. 2
> - fire the skript
> and so on.

I don't know how you can generate MASK files non-interactively but I've
used the following technique before to do several to save
me from waiting for the contours to be generated each time.

One thing you can do is create the mask files in advance and name them
something other than MASK. You can use the g.copy command to do the
naming. The key is to name the new Mask files with names that can be
easily generated in your script. The particular technique depends on the
scripting language you use and its abilities to do string manipulation.
For example in Perl you can create an array of numbers using the range
operator and then simply go through the array using the numbers as the
file names. That implies that you name your Mask files 1, 2, etc. Once you
can set up a loop to go through the different Masks simply use g.copy
again to copy the particular Mask file to the file MASK then do your
raster operation.

Of course this technique does not solve your problem of automatically
generating the MASK files but if the raster operations take any length of
time this will allow you to at least do those tasks automatically and save
you from waiting for each one to be done to generate your next MASK.

Hope this is of some use.


Jazzman (a.k.a. Justin Hickey)  e-mail: jhickey at
High Performance Computing Center
National Electronics and Computer Technology Center (NECTEC)
Bangkok, Thailand
People who think they know everything are very irritating to those
of us who do.  ---Anonymous

Jazz and Trek Rule!!!

More information about the grass-user mailing list