Has anyone else used r.stats as a quiet module in a GRASS-python script?

As part of my program I'm using:

grass.run_command("r.stats", flags='l', input=<file>, output=<*.csv file>, fs=',')

I'm using the 'l' flag here to print out category labels. If I change the flags to 'lq' r.stats does not produce the specified *.csv file. If I use the flags as '-q', r.stats runs as a quiet module, but it only creates a *.csv file with one row that describes the category values. For my output, I need both category values and their respective labels.

Any ideas?


The proper way to set the -q flag in a GRASS-Python script inside a grass.run_command() is quiet = True. In the example given in the question (for grass64), that would be:

grass.run_command("r.stats", flags='l', input=<file>, output=<*.csv file>, fs=',', quiet = True)

Read also the GRASS-Wiki page GRASS_Python_Scripting_Library for examples.

| improve this answer | |
  • Despite the original question being "old", it is still a valid one. – Nikos Alexandris May 19 '13 at 0:45

Okay so I figured out a solution. Probably will only work for GRASS-PYTHON codes.

In the environmental variables portion of my script I added:

os.environ['GRASS_VERBOSE']='0' #runs modules silently
| improve this answer | |

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.