[GRASS-user] Re: r.rescale categories definition
-C.R-
hartreim at gmx.net
Tue Jan 25 10:46:04 EST 2011
-C.R- wrote:
>
> 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=").
>
I think I solved the problem on my own changing Glynns script like this:
#!/bin/sh
inmap=$1
outmap=$2
to_min=$3
to_max=$4
min=$5
max=$6
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
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/r-rescale-categories-definition-tp4155847p5959296.html
Sent from the Grass - Users mailing list archive at Nabble.com.
More information about the grass-user
mailing list