[GRASS-user] How to rescale

Markus Metz markus.metz.giswork at googlemail.com
Mon Jan 9 15:04:05 EST 2012


On Mon, Jan 9, 2012 at 8:42 PM, leonidas <leonidas_liakos at yahoo.gr> wrote:
> I created a raster using *r.grow.distance*
> I need to rescale that file to a scale 0-255 but in reverse order where high
> values in distance file will be converted in low values to the rescaled
> file.
> I'm using the following command:
> *
> *
> But the output file has a range 60-255
> What's going wrong?
> Is there any better way to do that?

Try

eval `r.univar -g map=myrast`
r.mapcalc "myrast.invscaled = round((1.0 - myrast / $max) * 255.0)"

Original 0 will be 255, original maximum value will be 0, using
round() in order to get an integer map with rounded values which can
be exported as type Byte.

HTH,

Markus M


More information about the grass-user mailing list