1

Running r.stats in GRASS GIS from QGIS has no parameter for output, only one named html. Does anyone know why this is? It doesn't match the documentation https://grass.osgeo.org/grass78/manuals/r.stats.html Is there any way to persuade r.stats to output a CSV file? It would be much more useful for my purposes. Even if separator is set to comma, and a file with .csv is chosen as the output, it still outputs html format.

 processing.run("grass7:r.stats", 
        {'input':[input],
        'separator':'comma',
        'null_value':'*',
        'nsteps':255,
        'sort':0,
        '-1':False,
        '-A':True,
        '-a':True,
        '-c':False,
        '-p':False,
        '-l':True,
        '-g':False,
        '-x':False,
        '-r':False,
        '-n':False,
        '-N':False,
        '-C':False,
        '-i':False,
        'html':output,
        'GRASS_REGION_PARAMETER':None,
        'GRASS_REGION_CELLSIZE_PARAMETER':0})

1 Answer 1

0

The GRASS GIS module r.stats does not output html. it's quite easy to get the output as CSV by adding the parameter: separator=comma, i.e. (from the nc_spm_basin demo location):

micha@RMS:~$ r.stats -a -A -l slope separator=comma | head
 100%
0.075862,from zero slope to zero slope,2798016.389120
0.227585,from zero slope to zero slope,2459314.405205
0.379308,from zero slope to zero slope,2869916.810270
0.531031,from zero slope to 1 degree,3333719.526952
0.682754,from 1 degree to 1 degree,3757822.011093
0.834477,from 1 degree to 1 degree,4103424.035425
0.9862,from 1 degree to 1 degree,4390325.715925
1.137923,from 1 degree to 1 degree,4701927.541103
1.289646,from 1 degree to 1 degree,4906728.740707
1.44137,from 1 degree to 2 degrees,5138330.097291

Then a simple redirection (... >> stats_output.csv) would save to a file.

From the example in your question, it appears that you are using the QGIS processing framework. You neglected to mention this crucial detail, not in the title, nor the question, nor in the tags. So there's little chance that anyone with knowledge about the QGIS Processing toolbox will answer. I'd suggest that you either rephrase the question, or ask a new question, indicating how exactly you are running the module.

1
  • Noted, I've updated the question, sorry about that. Changing the separator to comma doesn't help. May 24, 2021 at 16:10

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.