[GRASS-user] Re: r.rescale categories definition

-C.R- hartreim at gmx.net
Tue Jan 25 10:26:59 EST 2011



Glynn Clements wrote:
> 
> You can get balanced intervals with:
> 
> #!/bin/sh
> inmap=$1
> outmap=$2
> to_min=$3
> to_max=$4
> eval `r.info -r $inmap`
> awk -vold_min=$min -vold_max=$max -vnew_min=$to_min -vnew_max=$to_max '
> BEGIN {
>   new_delta = new_max - new_min + 1
>   old_delta = old_max - old_min + 1
>   for (i = 0; i < new_delta; i++) {
>     lo = old_min + i     * old_delta / new_delta
>     hi = old_min + (i+1) * old_delta / new_delta - 1
>     new = new_min + i
>     printf("%d thru %d = %d %d\n", lo, hi, new, lo)
>   }
> }' | r.reclass in=$inmap out=$outmap
> 
> E.g.:
> 
> 	./rescale.sh elevation.dem elev.resc 1 4
> 


Hello Glynn Clements,

thanks for the nice shell-script you posted. It was very helpful.
But perhaps you can give me an answer to the following issue.
Is it possible to apply the script just to a small range of the attribute
values? I thought about an option like there is in modul r.rescale
("from=").

Cheers
Christoph
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-rescale-categories-definition-tp4155847p5959222.html
Sent from the Grass - Users mailing list archive at Nabble.com.


More information about the grass-user mailing list