[GRASS-dev] Get min and max value of the ranges reported by r.stats in case of fp input maps

Is there a way to get the minimum and maximum values separately for each of the ranges reported by fp in case of fp input maps?

I could use e.g., awk to separate the columns, but the problem is with negative values, like in the example below:

-1–2 | 5
-2-0 | 10
0-1 | 3

The minus sign and the dash to separate the minimum and maximum value of the range are the same character so separating by separator is not that straightforwards (or maybe / hopefully I am missing something obvious).

Paulo

Paulo van Breugel wrote:

Is there a way to get the minimum and maximum values separately for each of
the ranges reported by fp in case of fp input maps?

I could use e.g., awk to separate the columns, but the problem is with
negative values, like in the example below:

-1--2 | 5
-2-0 | 10
0-1 | 3

The minus sign and the dash to separate the minimum and maximum value of
the range are the same character so separating by separator is not that
straightforwards (or maybe / hopefully I am missing something obvious).

A '-' is a minus sign if it occurs at the beginning of the string or
immediately following another '-', otherwise it's a dash.

The following regexp should match the above syntax correctly:

^\(-\?[0-9]\+\)-\(-\?[0-9]\+\) *| *\([0-9]\+\) # basic RE syntax
^(-?[0-9]+)-(-?[0-9]+) *\| *([0-9]+) # extended RE syntax

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

Thanks, much appreciated. I think I sort of understand the syntax now I see it, but I definitely need to get more into this.

···

On Tue, Nov 20, 2012 at 7:09 PM, Glynn Clements <glynn@gclements.plus.com> wrote:

Paulo van Breugel wrote:

Is there a way to get the minimum and maximum values separately for each of
the ranges reported by fp in case of fp input maps?

I could use e.g., awk to separate the columns, but the problem is with
negative values, like in the example below:

-1–2 | 5
-2-0 | 10
0-1 | 3

The minus sign and the dash to separate the minimum and maximum value of
the range are the same character so separating by separator is not that
straightforwards (or maybe / hopefully I am missing something obvious).

A ‘-’ is a minus sign if it occurs at the beginning of the string or
immediately following another ‘-’, otherwise it’s a dash.

The following regexp should match the above syntax correctly:

^(-?[0-9]+)-(-?[0-9]+) *| *([0-9]+) # basic RE syntax
^(-?[0-9]+)-(-?[0-9]+) *| *([0-9]+) # extended RE syntax


Glynn Clements <glynn@gclements.plus.com>