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.

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
add comment

2 Answers 2

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
add comment

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
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.