[GRASS-dev] GRASS 7 r.neighbours average method giving incorrect value

Markus Metz markus.metz.giswork at gmail.com
Thu Jul 11 05:24:44 PDT 2013


On Thu, Jul 11, 2013 at 1:30 PM, Glynn Clements
<glynn at gclements.plus.com> wrote:
>
> Allar Haav wrote:
>
>> I noticed today that "average" method in r.neighbours gives an incorrect
>> value. Let me give you an example:
>
>> 3) Judging from previous steps, it should be only logical that the
>> output raster has values from 0 to 1. However it seems that 0.5 has been
>> added:
>
>
> When the output is an integer map, the result of the average, variance
> and stddev methods is supposed to be rounded to the nearest integer
> (rather than towards zero), so 0.5 is added prior to truncation.

For rounding of negative values, 0.5 would need to be subtracted, not
added prior to truncation. See e.g. r.mapcalc's round().

Currently (in G6), the output map type is the same like the input map
type. For an integer map with zeros and ones, the average will never
be anything close to 0.5, but always either zero or one, not realistic
and most probably not desired.

I would rather have DCELL output all the times, maybe keep the maptype
for min, max?

Markus M


More information about the grass-dev mailing list