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

Moritz Lennert mlennert at club.worldonline.be
Thu Mar 1 15:48:21 EST 2012


On 01/03/12 17:59, Glynn Clements wrote:
>
> Moritz Lennert wrote:
>
>> If you want to work in a python script, you have to first run
>> read_command(g.mlist),
>
> You can use mlist_grouped(), but it currently only works with glob
> patterns, not regexps. Alternatively, you can use list_grouped,
> list_pairs or list_strings and manually filter the result. E.g.:
>
> 	import grass.script as grass
>
> 	maps = [map
> 	        for map in grass.list_strings('rast')
> 	        if map.startswith('rast_') or map.startswith('crast_')]
> 	maps = ','.join(maps)
>
> 	grass.run_command("r.series", input = maps, ...)
>


Any reason why the solution using splitlines() is not acceptable:

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