[GRASS-user] List of existing values

Greetings

I have a raster map with a lot of values and I want to retrieve a list of the existing values. How can I do that in GRASS?
Thanks
Nikos

Am Dienstag, den 20.07.2010, 14:14 +0100 schrieb Nikos Dumakis:

Greetings

I have a raster map with a lot of values and I want to retrieve a list
of the existing values. How can I do that in GRASS?
Thanks
Nikos

Hi Nikos,

r.stats will do this job

Best,

Manfred

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Greetings Dr. Redslob
I have opened r.stats and I cannot find any method/option to print existing values. It prints numbers of values between ranges of values among others but no list of values. Or am I missing some option?
Thank you
Best regards
Nikos

On Tue, Jul 20, 2010 at 2:06 PM, Dr. Manfred Redslob <redslob@gdf-hannover.de> wrote:

Am Dienstag, den 20.07.2010, 14:14 +0100 schrieb Nikos Dumakis:

Greetings

I have a raster map with a lot of values and I want to retrieve a list
of the existing values. How can I do that in GRASS?
Thanks
Nikos

Hi Nikos,

r.stats will do this job

Best,

Manfred


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Hi,

2010/7/20 Nikos Dumakis <nikosdu1980@gmail.com>:

I have opened r.stats and I cannot find any method/option to print existing
values. It prints numbers of values between ranges of values among others
but no list of values. Or am I missing some option?

  -1 One cell (range) per line

?

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Greetings
In my case I have not more than 1200 different cell values. If I do :
r.stats -1 input=data
I obtained a list of all pixel values but what I am lookinf is for the unique values (not repeated).

I just need the unique values not all values (repeated)
(maybe I was not clear in my previous messages… I’m sorry

On Tue, Jul 20, 2010 at 2:38 PM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

2010/7/20 Nikos Dumakis <nikosdu1980@gmail.com>:

I have opened r.stats and I cannot find any method/option to print existing
values. It prints numbers of values between ranges of values among others
but no list of values. Or am I missing some option?

-1 One cell (range) per line

?

Martin


Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Hi,

2010/7/20 Nikos Dumakis <nikosdu1980@gmail.com>:

In my case I have not more than 1200 different cell values. If I do :
r.stats -1 input=data
I obtained a list of all pixel values but what I am lookinf is for the
unique values (not repeated).

as mentioned in Hamish's response, use combination of `sort` and `uniq`

r.starts -1 input=data | sort | uniq

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

THanks Martin. It works
Just one last question. This is applying Shell Scripts right? Can I do the same but with Python Scripts

On Tue, Jul 20, 2010 at 4:17 PM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

2010/7/20 Nikos Dumakis <nikosdu1980@gmail.com>:

In my case I have not more than 1200 different cell values. If I do :
r.stats -1 input=data
I obtained a list of all pixel values but what I am lookinf is for the
unique values (not repeated).

as mentioned in Hamish’s response, use combination of sort and uniq

r.starts -1 input=data | sort | uniq

Martin


Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

hELLO all
Regarding the use of r.stats -1 input=image | sort | uniq
I have sent a message saying that this works just fine but…

I have only tested in WinGRASS 6.4.RC6). When I tried in Linux (GRASS6.4.0RC6) I got this error:

Sorry <|> is not a valid option
Sorry is not a valid option
Sorry <|> is not a valid option
Sorry is not a valid option

Why do I obtain different results in Win and in Linux? and How can I do this in Linux?

Thanks
Nikos

On Tue, Jul 20, 2010 at 4:17 PM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

2010/7/20 Nikos Dumakis <nikosdu1980@gmail.com>:

In my case I have not more than 1200 different cell values. If I do :
r.stats -1 input=data
I obtained a list of all pixel values but what I am lookinf is for the
unique values (not repeated).

as mentioned in Hamish’s response, use combination of sort and uniq

r.starts -1 input=data | sort | uniq

Martin


Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Nikos Dumakis:

> In my case I have not more than 1200 different cell values. If I do :
> r.stats -1 input=data
> I obtained a list of all pixel values but what I am lookinf is for the
> unique values (not repeated).

Martin Landa wrote:

as mentioned in Hamish's response, use combination of `sort` and `uniq`

r.starts -1 input=data | sort | uniq

shorter:

r.starts -1 input=data | sort -u

Nikos

Martin Landa wrote:

> as mentioned in Hamish's response, use combination of
> `sort` and `uniq`
>
> r.starts -1 input=data | sort | uniq

shorter:

r.starts -1 input=data | sort -u

AFAIR, those are not the same thing and can not be used
interchangeably. (although I don't fully remember why right now)

anyway, for floating point maps I still think it's a bad idea.

I'm sure there is a Python equivalent of 'sort|uniq', but don't
know what it is.

'sort' and 'uniq' are UNIX command line power tools and not
available in MS Windows. But.. the MSys command prompt that
ships with WinGrass supplies them and you can use them there.
I suppose the "bin" dir where they are kept are not part of the
gui's PATH which is why they wouldn't work from the Cmd> gui
prompt.

Hamish

Martin Landa wrote:

> > as mentioned in Hamish's response, use combination of
> > `sort` and `uniq`
> > r.starts -1 input=data | sort | uniq

Nikos:

> shorter:
> r.starts -1 input=data | sort -u

Hamish wrote:

AFAIR, those are not the same thing and can not be used
interchangeably. (although I don't fully remember why right now)

It has troubled me as well (now and in the past). I did (before posting the
above) a quick test using a column from a vector map containing strings. I
counted the result from both "uniq" and "sort -u" with "| wc -l". The results
were identical.

So... :-? Maybe it is ok for strings/integers(?). One should be more careful
with those "knifes".

Nikos

anyway, for floating point maps I still think it's a bad idea.

I'm sure there is a Python equivalent of 'sort|uniq', but don't
know what it is.

'sort' and 'uniq' are UNIX command line power tools and not
available in MS Windows. But.. the MSys command prompt that
ships with WinGrass supplies them and you can use them there.
I suppose the "bin" dir where they are kept are not part of the
gui's PATH which is why they wouldn't work from the Cmd> gui
prompt.

Martin Landa wrote:

> > > as mentioned in Hamish's response, use combination of
> > > `sort` and `uniq`
> > > r.starts -1 input=data | sort | uniq

Nikos:

> > shorter:
> > r.starts -1 input=data | sort -u

Hamish:

> AFAIR, those are not the same thing and can not be used
> interchangeably. (although I don't fully remember why right now)

Nikos:

It has troubled me as well (now and in the past). I did (before posting the
above) a quick test using a column from a vector map containing strings. I
counted the result from both "uniq" and "sort -u" with "| wc -l". The
results were identical.

So... :-? Maybe it is ok for strings/integers(?). One should be more
careful with those "knifes".

Hamish:

> anyway, for floating point maps I still think it's a bad idea.
>
> I'm sure there is a Python equivalent of 'sort|uniq', but don't
> know what it is.
>
> 'sort' and 'uniq' are UNIX command line power tools and not
> available in MS Windows. But.. the MSys command prompt that
> ships with WinGrass supplies them and you can use them there.
> I suppose the "bin" dir where they are kept are not part of the
> gui's PATH which is why they wouldn't work from the Cmd> gui
> prompt.

Here some details from "(coreutils.info.gz)sort invocation":

--%<---
`-u'
`--unique'
     Normally, output only the first of a sequence of lines that compare
     equal. For the `--check' (`-c' or `-C') option, check that no
     pair of consecutive lines compares equal.

     This option also disables the default last-resort comparison.

     The commands `sort -u' and `sort | uniq' are equivalent, but this
     equivalence does not extend to arbitrary `sort' options. For
     example, `sort -n -u' inspects only the value of the initial
     numeric string when checking for uniqueness, whereas `sort -n |
     uniq' inspects the entire line. *Note uniq invocation::.
--->%--

Nikos

On Friday 23 of July 2010 08:58:09 Nikos Alexandris wrote:

Martin Landa wrote:
> > > > as mentioned in Hamish's response, use combination of
> > > > `sort` and `uniq`
> > > > r.starts -1 input=data | sort | uniq

Nikos:
> > > shorter:
> > > r.starts -1 input=data | sort -u

Hamish:
> > AFAIR, those are not the same thing and can not be used
> > interchangeably. (although I don't fully remember why right now)

Nikos:
> It has troubled me as well (now and in the past). I did (before posting
> the above) a quick test using a column from a vector map containing
> strings. I counted the result from both "uniq" and "sort -u" with "| wc
> -l". The results were identical.
>
> So... :-? Maybe it is ok for strings/integers(?). One should be more
> careful with those "knifes".

Hamish:
> > anyway, for floating point maps I still think it's a bad idea.
> >
> > I'm sure there is a Python equivalent of 'sort|uniq', but don't
> > know what it is.
> >
> > 'sort' and 'uniq' are UNIX command line power tools and not
> > available in MS Windows. But.. the MSys command prompt that
> > ships with WinGrass supplies them and you can use them there.
> > I suppose the "bin" dir where they are kept are not part of the
> > gui's PATH which is why they wouldn't work from the Cmd> gui
> > prompt.

Here some details from "(coreutils.info.gz)sort invocation":

--%<---
`-u'
`--unique'
     Normally, output only the first of a sequence of lines that compare
     equal. For the `--check' (`-c' or `-C') option, check that no
     pair of consecutive lines compares equal.

     This option also disables the default last-resort comparison.

     The commands `sort -u' and `sort | uniq' are equivalent, but this
     equivalence does not extend to arbitrary `sort' options. For
     example, `sort -n -u' inspects only the value of the initial
     numeric string when checking for uniqueness, whereas `sort -n |
     uniq' inspects the entire line. *Note uniq invocation::.
--->%--

And something more from "man uniq" (a reminder to avoid using "uniq" on its
own):

--%<---
Note: 'uniq' does not detect repeated lines unless they are adjacent. You may
want to
       sort the input first, or use `sort -u' without `uniq'. Also,
comparisons honor the
       rules specified by `LC_COLLATE'.
-->%---

Nikos