[GRASS-dev] GRASS-dev] On i.histo.match (Re: On (Landsat) imagery naming patterns)

Moritz Lennert mlennert at club.worldonline.be
Thu Aug 1 04:42:03 PDT 2013


On 01/08/13 13:43, Nikos Alexandris wrote:
> Michael:
>
>>>>>> What about just using r.rescale to rescale this?
>
> Nikos:
>
>>>>> Already tried (in the past) and I don't think it works from DCELL>
>>>>> 8-bit. It seems to chew-up (silently, as Moritz mentioned I think among
>>>>> the lines in ticket #2^11) values.
>
>>>>> It seems that "integerising" manually, in this case, is the best
>>>>> approach. With the essential question remaining on "how many fine digits
>>>>> should be preserved?".
>
> Moritz:
>
>>>> r.rescale is just a frontend to r.reclass. and as such is meant for CELL
>>>> maps. It should'nt make a difference whether it is 8-bit or more, though.
>>>> For DCELL you can try to use r.recode.
>
> Nikos:
>
>>> Didn't work also (tried the previous days) -- I can try again.
>
> Moritz:
>
>> Please be more precise than "didn't work"...
>
> Right, "be more precise" is the key to "freedom" :D.  Indeed, I used to say
> (either in a "rules" file, or directly using "...<<  EOF"
>
> 0.0:1.0:0:255
>
> This did not work.  Both stats and histogram of the recoded raster map, e.g. a
> Red-Reflectance image ranging in
>
> r.info Red_ToAR -r
>
> min=0
> max=0.774115699104528
>
> were kinda flattened out
>
> r.stats Red_ToAR_recoded_255
>   100%
>
> 0
> 255
>
> Looking at the image I want to recode
>
> r.stats Red_ToAR | head
>   100%
>
> 0-0.003036
> 0.02125-0.024286
> 0.024286-0.027322
> 0.027322-0.030357
> 0.030357-0.033393
> 0.033393-0.036429
> 0.036429-0.039465
> 0.039465-0.0425
> 0.0425-0.045536
> 0.045536-0.048572
>
> I altered the rules file like
>
> 0.001:1.0:0:255
>
>
> This works-out!  Now, the recoded image is
>
> r.recode in=Red_ToAR out=Red_ToAR_recoded_255 rules=recode_rules  --o
> r.stats Red_ToAR_recoded_255
>   100%
> 5
> 6
> 7
> .
> ..
> ...  \
> ....>  Many values in-between
> ...  /
> ..
> .
> 195
> 196
> 197
> *
>
> And the histogram looks "nice" as well. I didn't grasp that -- from where
> should I?  In the manual there is only an example from int to float (however,
> indeed, instructing 0.1 as the "target" min value).

There does seem to be a bug in r.recode. Your first rule set should work 
if you set the -d flag. Maybe you can file a ticket ?

Moritz


More information about the grass-dev mailing list