Martin Wegmann wrote:
Carlos Grohmann and I created a script as substitute for v.cellstats.
It would be great if somebody can look through it to give feed-back
how to improve it before we post it to the WIKI.
Hi Martin,
how does this script's function differ from the new r.resamp.stats
module?
script notes: (many are general comments for all grass scripts)
* _v._cellstats, but it imports and exports raster maps!
* use standard input= and output= option names for consistency.
make input= the first option
* output maps should use the "new,cell,raster". This way --overwrite
works, etc
#% key: raster
#% gisprompt: old,cell,raster
* for method key, use "options:" line to specify available methods.
#% options: n,min,max,range,sum,mean,stddev,variance,coeff_var
* redirect status messages to stderr: (helps parsing output to a file)
echo "You must be in GRASS GIS to run this program" 1>&2
* export cell x,y,z to file directly:
was:
#convert to vect and export as ascii
r.to.vect -z input=$GIS_OPT_raster output=tmp_vect feature=point
v.out.ascii input=tmp_vect output=xyz_file format=point
easier:
r.stats -1ng "$GIS_OPT_raster" > xyz_file
(as this is impossible to guess without prior experience, I've just
written a simple wrapper script called r.out.xyz, now in 6.3cvs.
maybe better as an option to r.out.ascii?)
* use "r.to.vect -b" so the script can work with larger grids
(1500x1500) input -> 2.25million vector point & memory problems
if topology is built. Also, r.in.xyz has to keep the entire map in
memory, so hard-coding percent=100 for Very large grids could cause
problems.
* use g.tempfile (script won't work if in a non writeable dir, eg "/")
see grass scripts/ for an example of doing that safely
(e.g. r.univar.sh)
* double quote all "$VARIABLES". legal map names may include restricted
shell chars, filenames may include spaces.
cheers,
Hamish