Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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

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.

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

Your Answer


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.