Markus Neteler wrote:

>> 1) "quantile=0.5" creeps into the history:

>>

>> r.info landuse96_28m_mode7x7

>> ...

>> | r.neighbors input="landuse96_28m" output="landuse96_28m_mode7x7" met\ |

>> | hod="mode" size=3 quantile=0.5

>>

>> --> quantile=0.5 should not be there (even if ignored).

>

> Remove the line:

>

> parm.quantile->answer = "0.5";

>

> Optionally change:

>

> out->quantile = (parm.quantile->answer && parm.quantile->answers[i])

> ? atof(parm.quantile->answers[i])

> : 0;

>

> to default to 0.5 rather than 0.

>

> But given that we already a distinct "median" method, using

> "quantile=0.5" is largely redundant.

... mmh, not sure what to change.

Fixed in r60345.

>> 2) The method=mode does not preserve CELL (likewise in r.series).

Note that the same issue applies to minimum, maximum, range, and

(unweighted) sum.

This is a bit over my programming skills.

But the broken "mode" operator is a critical issue.

Help (=svn commits) welcome,

r60346 implements the following logic:

For any aggregate, there are 2 factors affecting the output type:

1. Whether the input map is integer or floating-point.

2. Whether the weighted or unweighted version of the aggregate is used.

These combine to create 4 possibilities:

type integer integer float float

weighted no yes no yes

average float float float float

median [1] [1] float float

mode integer integer [2] [2]

minimum integer integer float float

maximum integer integer float float

range integer integer float float

stddev float float float float

sum integer float float float

count integer float integer float

variance float float float float

diversity integer integer integer integer

interspersion integer integer integer integer

quart1 [1] [1] float float

quart3 [1] [1] float float

perc90 [1] [1] float float

quantile [1] [1] float float

[1] For integer input, quantiles may produce float results from

interpolating between adjacent values.

[2] Calculating the mode of floating-point data is essentially

meaningless.

With the current aggregates, there are 5 cases:

1. Output is always float: average, variance, stddev, quantiles (with

interpolation).

2. Output is always integer: diversity, interspersion.

3. Output is integer if unweighted, float if weighted: count.

4. Output matches input: minimum, maximum, range, mode (subject to

note 2 above), quantiles (without interpolation).

5. Output is integer for integer input and unweighted aggregate,

otherwise float: sum.

--

Glynn Clements <glynn@gclements.plus.com>