[GRASS-user] Get non-NULL cells over multiple rasters

Moritz Lennert mlennert at club.worldonline.be
Thu Mar 1 09:28:38 EST 2012


Moritz Lennert wrote:
> Johannes Radinger wrote:
>> 2) and I tried it in a python script with:
>> grass.run_command("r.series",
>> input = "'g.mlist pattern='rast_*|crast_*|Treene_raster' sep=,'",
>> overwrite=True,
>> flags = "n",
>> output = "Treene_tmp_mask",
>> method = "count")
>
>
> If you want to work in a python script, you have to first run
> read_command(g.mlist), put the result in a comma-seperated string which
> you then feed into r.series. There are possibly other ways that I don't
> know about...

Something like this:

maps=grass.read_command('g.mlist', 
pattern='rast_*|crast_*|Treene_raster', type='rast').splitlines()

grass.run_command("r.series", input=maps, out="Treene_tmp_mask", 
method="count", flags="n", overwrite=True)

Moritz


More information about the grass-user mailing list