[GRASS-user] Use of g.mlist inside r.series

Hi,

I am using following Python code to add all raster maps with wildcard name: viewshed*.

grass.run_command (“r.series”, input="g.mlist pattern = 'viewshed*' sep =, ", output = ‘xx’, method = ‘sum’)

But it does not work saying:

WARNING: Illegal filename <g.mlist pattern = 'viewshed*' sep =>. Character < > not allowed. ERROR: Raster map <g.mlist pattern = ‘viewshed*’ sep => not found

What is the possible error? I am using GRASS in Windows7

Hi,

2013/1/10 Brian Sanjeewa Rupasinghe <jinkabs@gmail.com>:

grass.run_command ("r.series", input="`g.mlist pattern = 'viewshed*' sep =,
`", output = 'xx', method = 'sum')

you cannot use bash-like constructions in Python script. Try

maps = grass.mlist_strings(type = 'rast', pattern = 'viewshed*')
grass.run_command ("r.series", input = maps, output = 'xx', method = 'sum')

Martin

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa

Many Thanks Martin. It worked fine.

Cheers, Brian

On Thu, Jan 10, 2013 at 6:55 PM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

2013/1/10 Brian Sanjeewa Rupasinghe <jinkabs@gmail.com>:

grass.run_command (“r.series”, input="g.mlist pattern = 'viewshed*' sep =, ", output = ‘xx’, method = ‘sum’)

you cannot use bash-like constructions in Python script. Try

maps = grass.mlist_strings(type = ‘rast’, pattern = ‘viewshed*’)
grass.run_command (“r.series”, input = maps, output = ‘xx’, method = ‘sum’)

Martin


Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa