On Thu, Mar 24, 2011 at 6:07 PM, Glynn Clements <[email protected]> wrote: > > Johannes Radinger wrote: > >> I think r.mapcalc is probably the best solution, but as I don't know the >> maximum >> value in every case (I've to process several maps), I wanted to automatize. >> Probably I've to write a script to read the max value and parse it to the >> mapcalc function. >> My problem: First, I don't know how to do that, Second there is this >> python-script issue >> on my mac (see other thread)... > > "r.info -r ..." will output the minimum and maximum values. > > For a shell script, you can use e.g.: > > eval `r.info -r $inmap` > r.mapcalc "$outmap = float($inmap) / $max"
Added here: http://grass.osgeo.org/wiki/GRASS_and_Shell#Using_output_from_GRASS_modules_in_the_script > For a Python script, you can use grass.script.raster_info(), e.g.: > > import grass.script as grass > > max = grass.raster_info(inmap)['max'] > grass.mapcalc("$outmap = $inmap / $max", > inmap = inmap, outmap = outmap, max = max) Added here: http://grass.osgeo.org/wiki/GRASS_and_Python#Using_output_from_GRASS_modules_in_the_script Markus _______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
