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

Glynn Clements glynn at gclements.plus.com
Thu Mar 24 13:07:06 EDT 2011


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"

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)

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list