[GRASS-dev] Some proposition on r.neighbour (new code)

Hi All

I have two propositions on r.neighbour:

1) add existing method "range" to existing methods of r.neighbors
it is only only one line:

    {c_max, NULL, NO_CATS, 1, 0, "maximum", "highest value"},
+ {c_range, NULL, NO_CATS, 1, 0, "range", "maximum - minimum"},
    {c_stddev, w_stddev, NO_CATS, 0, 1, "stddev", "standard deviation"},

reason:
parameter "range" can be calculated as max-min, but it require three calculation: r.neigbour twice, and r.mapcalc one. For large maps and large window it takes lot of time. That parameter is broadly used in geomorphology as "relief energy" equivalent and as far as I know is frequently calculated (of course not only in GRASS GIS)

2) add new method "percentile" and add it to existing method of r.neighbours

I attached code as percentile2.c. For testing purpose I added it to directory r.neighbors, and add one line into methods:

    {c_perc, NULL, NO_CATS, 0, 0, "percentile", "percentile of center value"},

reason:
method "percentile" returns the percentile of the central cell. If it is max cell in the neighbor it returns 1 in smallest it returns 1/cell_count.
That parameter can be use in geomorphology to determine valleys (usually values lower than first quartile: 0.25) and ridges (usually values grater than 3th quartile 0.75). I send it to GRASS DEV Because I'd like to share this code with other grass users, and the easiest way is to add this parameter to GRASS is expand r.neighbors (creating ADD_ON r.neigbors fork or completely new module only for one parameter is nonsense).

regards
Jarek Jasiewicz

(attachments)

percentile2.c (674 Bytes)

Jarosław Jasiewicz wrote:

I have two propositions on r.neighbour:

1) add existing method "range" to existing methods of r.neighbors

2) add new method "percentile" and add it to existing method of r.neighbours

Both seem reasonable, although I'm not keen on the name of the second.

1. It's likely to be confused as being similar to quart1, quart3,
perc90 and quantile (quantile would have been named percentile if it
used values in the range 0-100 rather than 0-1).

2. The name shouldn't mention percentile unless the range is 0-100.

--
Glynn Clements <glynn@gclements.plus.com>

Glynn Clements pisze:

Jaros³aw Jasiewicz wrote:

I have two propositions on r.neighbour:

1) add existing method "range" to existing methods of r.neighbors
    
2) add new method "percentile" and add it to existing method of r.neighbours
    
Both seem reasonable, although I'm not keen on the name of the second.
  1. It's likely to be confused as being similar to quart1, quart3,
perc90 and quantile (quantile would have been named percentile if it
used values in the range 0-100 rather than 0-1).
  

maybe name "quantile" will be better, in general the idea of function is to return relation the central value to the neigbor (similar to interspersion)

2. The name shouldn't mention percentile unless the range is 0-100.
  

you right, it is only the issue of multiply the result by 100, of course it never be 0, because there always 1 cell equal to the center (this one).

I'm not sure which solution could be better: quantile 0-1 or percentile 0-100?,

regards
Jarek

Jarosław Jasiewicz wrote:

>> I have two propositions on r.neighbour:
>>
>> 1) add existing method "range" to existing methods of r.neighbors
>>
>
>
>> 2) add new method "percentile" and add it to existing method of r.neighbours
>>
>
> Both seem reasonable, although I'm not keen on the name of the second.
>
> 1. It's likely to be confused as being similar to quart1, quart3,
> perc90 and quantile (quantile would have been named percentile if it
> used values in the range 0-100 rather than 0-1).
>
maybe name "quantile" will be better,

method=quantile already exists; it calculates the value at an
arbitrary quantile specified by the quantile=... option. The following
pairs of commands are equivalent:

r.neighbors method=quantile quantile=0.25 / r.neighbors method=quart1
r.neighbors method=quantile quantile=0.50 / r.neighbors method=median
r.neighbors method=quantile quantile=0.75 / r.neighbors method=quart3
r.neighbors method=quantile quantile=0.90 / r.neighbors method=perc90

In general, where a module offers a quantile (percentile, quartile,
etc) option, the quantile is chosen by the user and the value at that
quantile is returned, so using the terms percentile or quantile alone
in this case may lead to confusion.

OTOH, I don't have any suggestions as to a better name.

--
Glynn Clements <glynn@gclements.plus.com>

Glynn Clements pisze:

Jaros³aw Jasiewicz wrote:

I have two propositions on r.neighbour:

1) add existing method "range" to existing methods of r.neighbors
    
2) add new method "percentile" and add it to existing method of r.neighbours
    

Both seem reasonable, although I'm not keen on the name of the second.
  1. It's likely to be confused as being similar to quart1, quart3,
perc90 and quantile (quantile would have been named percentile if it
used values in the range 0-100 rather than 0-1).
  

maybe name "quantile" will be better,
    
method=quantile already exists; it calculates the value at an
arbitrary quantile specified by the quantile=... option. The following
pairs of commands are equivalent:

r.neighbors method=quantile quantile=0.25 / r.neighbors method=quart1
r.neighbors method=quantile quantile=0.50 / r.neighbors method=median
r.neighbors method=quantile quantile=0.75 / r.neighbors method=quart3
r.neighbors method=quantile quantile=0.90 / r.neighbors method=perc90

In general, where a module offers a quantile (percentile, quartile,
etc) option, the quantile is chosen by the user and the value at that
quantile is returned, so using the terms percentile or quantile alone
in this case may lead to confusion.

OTOH, I don't have any suggestions as to a better name.

maybe relative position? or relative and description "relative position to neigbor cells"
J.