Johannes Radinger wrote:
Hi,
-------- Original-Nachricht --------
Datum: Thu, 01 Mar 2012 13:18:30 +0100
Von: Moritz Lennert<[email protected]>
An: Johannes Radinger<[email protected]>
CC: GRASS user list<[email protected]>
Betreff: Re: [GRASS-user] Get non-NULL cells over multiple rasters
Johannes Radinger wrote:
Hi,
I have a bunch of raster maps (~50 are named crast_* and 50 are named
rast_*). Is there a simple way (eg. using regular expressions) to
process them with the mapcalculator to get one resulting map which
shows only those cells (value 1) which are non-NULL cell in ALL maps?
Like I'd like the cells which all rasters have commonly populated.
Maybe there is a simple way to do this in the mapcalculator (or any
other modul) resp. in a python script?? Suggestions are mostly
welcome. Thanks,
r.series with the -n flag ? From the man page:
"With -n flag, any cell for which any of the corresponding input cells
are NULL is automatically set to NULL (NULL propagation). The aggregate
function is not called, so all methods behave this way with respect to
the -n flag."
See the man page for examples of how to use r.series in conjunction with
g.mlist to work with a series of maps.
Thank you very much, r.series is the right tool for my task. I tried to
use it in combination with g.mlist but somehow I don't manage it. I tried
different methods e.g.:
1) in the GRASS command console I typed:
r.series -n input="'g.mlist pattern='rast_*|crast_*' sep=,'"
output=Treene_tmp_mask method=count
Are you talking about the wxGUI command console, or the terminal ?
In the terminal the whole g.mlist part has to be in backticks (`) which
means "replace everything which is within the backticks with the results
of that command". I imagine that this does not work in the GUI command
console.
In the terminal your command should be:
r.series -n input=`g.mlist pattern="rast_*|crast_*" sep=,`
output=Treene_tmp_mask method=count
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...
Moritz
_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user