[GRASS-user] g.list in a python script

Micha Silver micha at arava.co.il
Sat Aug 13 10:30:25 PDT 2016


In a python script, I am doing g.list to get a certain set of rasters, 
then r.series to sum the values. I find that g.list adds a newline 
character at the end of the string, and that causes r.series to fail. 
I've added the python rstrip('\n') to avoid this.
Is that the expected output from g.list?

Here's the code that works:

rast_list = gscript.read_command('g.list', type='rast', 
separator='comma', pattern='ims_*')
rast_list = rast_list.rstrip('\n')
gscript.run_command('r.series', input=rast_list, output=ttl_ims_precip, 
method='sum', overwrite=True)

Without the "rstrip" call, then r.series fails.

This is on Mint 18 with grass 7.0.4


More information about the grass-user mailing list