[GRASS-user] r.rescale - float instead of integer?

Markus Neteler neteler at osgeo.org
Fri Mar 25 04:27:11 EDT 2011


On Thu, Mar 24, 2011 at 6:07 PM, Glynn Clements
<glynn at gclements.plus.com> 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


More information about the grass-user mailing list