I am new to Python and scripting in general.
My overall goal is to create a script that I can cycle through all the raster maps in a mapset and then save the univariate stats to a .csv file for each raster map. I am working on the first part: cycling through all the maps and printing the stats to the terminal window. Later, I will try and save the data to a .csv file. I have seven maps in my practice mapset and I get seven errors, but my problem is that I do not know what variable to assign to the parameter MAP (hopefully, I stated that correctly).
Here is what I have thus far:
import sys
import os
import grass.script as grass
import grass.script.setup as gsetup
gisbase = os.environ['GISBASE']
gisdb="/Users/kc/GrassData"
location="Data_2013"
mapset="methods_check"
gsetup.init(gisbase, gisdb, location, mapset)
grass.run_command("g.list", _type="rast")
mymaps = grass.parse_command("g.list", _type="rast")
print len(mymaps)
for items in mymaps:
grass.run_command('r.univar', map='items', separator=",")
What should I put for map = 'items' so that it cycles through all the raster maps of a mapset?
I am using GRASS 7.0, but the same thing happens in GRASS 6.5. In Grass 6.5, the parameter separator must be changed to fs. Both versions label the input file "map".