[GRASS-user] Re: Command to summarize the frequency distribution table

Dear Moritz and all

r.stats or r.report

Thank you for profitable advice.
When this command was used, the table is output as follows:.

|---------------------------------------------------|
| Category Information | square |
| #|description |kilometers|
|---------------------------------------------------|
| 1| . . . . . . . . . . . . . . . . . .| 37.30|
| 2| . . . . . . . . . . . . . . . . . .| 5.89|
| 3| . . . . . . . . . . . . . . . . . .| 5.89|
| 4| . . . . . . . . . . . . . . . . . .| 7.85|

I want to obtain the frequency distribution table into which the class was
divided.

> -------------------------------
> height number of cells
> -------------------------------
> 0 - 10 m 100
> 11 - 20 m 200
> 21 - 30 m 50
> ........ xxx
> ------------------------------

Do I have to divide the class by using this output result?
Or, is there another command or parameter of the class division?

Regards, Yasuo shimada
--------

Message: 1
Date: Sun, 07 Dec 2008 22:29:54 +0100
From: Moritz Lennert <mlennert@club.worldonline.be>
Subject: Re: [GRASS-user] Command to summarize the frequency
  distribution table
To: shimada@jwa.or.jp
Cc: grass-user@lists.osgeo.org
Message-ID: <493C4052.50407@club.worldonline.be>
Content-Type: text/plain; charset=ISO-2022-JP

On 07/12/08 13:45, SGW00412@nifty.com wrote:
> Dear all
>
> I'm a beginner grass user.
>
> I made the raster map of altitude from GTOP30.
>
> So, I want to obtain a frequency distribution table in the altitude.
>
> For instance:
>
> -------------------------------
> height calls number of cells
> -------------------------------
> 0 - 10 m 100
> 11 - 20 m 200
> 21 - 30 m 50
> ........ xxx
> ------------------------------
>
> But I do not understand what kind of commands to use.

r.stats or r.report

Moritz

On 09/12/08 15:43, SGW00412@nifty.com wrote:

Dear Moritz and all

r.stats or r.report

Thank you for profitable advice. When this command was used, the table is output as follows:.

|---------------------------------------------------|
| Category Information | square |
| #|description |kilometers|
|---------------------------------------------------|
| 1| . . . . . . . . . . . . . . . . . .| 37.30|
| 2| . . . . . . . . . . . . . . . . . .| 5.89|
| 3| . . . . . . . . . . . . . . . . . .| 5.89|
| 4| . . . . . . . . . . . . . . . . . .| 7.85|

This means that your elevation map is already a reclassified map with
elevation classes, but that you did not include the information about
the classes in the reclassed map. I.e., using r.reclass, you can do
something like this:

0 thru 10 = 1

but if you want to keep the information about the class amplitude, then
you have to do this (adding a label to each class):

0 thru 10 = 1 0 - 10m

You can also add labels to the existing classes, using r.category. Just
create a text file:

1: 0 - 10 m
2:11 - 20 m
3:21 - 30 m
...

and run r.category map=YourMap rules=TextFile.

Then r.report will include these labels.

Moritz

Dear Moritz:

I wish to express my gratitude for your valuable advice. Thank you.
It succeeded when having tried as follows:

0 thru 100=1 0-100m
100 thru 200=2 100-200m
200 thru 300=3 200-300m
300 thru 400=4 300-400m
....
end

save as alt_class.txt

r.reclass input=old_rast_map output=new_rast_map < alt_class.txt

r.stats new_rast_map -c

Thanks !!

Best regard
Yasuo shimada
----
Moritz Lennert <mlennert@club.worldonline.be>‚³‚ñF

On 09/12/08 15:43, SGW00412@nifty.com wrote:
> Dear Moritz and all
>
>> r.stats or r.report
>
> Thank you for profitable advice.
> When this command was used, the table is output as follows:.
>
> |---------------------------------------------------|
> | Category Information | square |
> | #|description |kilometers|
> |---------------------------------------------------|
> | 1| . . . . . . . . . . . . . . . . . .| 37.30|
> | 2| . . . . . . . . . . . . . . . . . .| 5.89|
> | 3| . . . . . . . . . . . . . . . . . .| 5.89|
> | 4| . . . . . . . . . . . . . . . . . .| 7.85|

This means that your elevation map is already a reclassified map with
elevation classes, but that you did not include the information about
the classes in the reclassed map. I.e., using r.reclass, you can do
something like this:

0 thru 10 = 1

but if you want to keep the information about the class amplitude, then
you have to do this (adding a label to each class):

0 thru 10 = 1 0 - 10m

You can also add labels to the existing classes, using r.category. Just
create a text file:

1: 0 - 10 m
2:11 - 20 m
3:21 - 30 m
...

and run r.category map=YourMap rules=TextFile.

Then r.report will include these labels.

Moritz

On 16/12/08 14:40, SGW00412@nifty.com wrote:

Dear Moritz:

I wish to express my gratitude for your valuable advice. Thank you. It succeeded when having tried as follows:

0 thru 100=1 0-100m
100 thru 200=2 100-200m
200 thru 300=3 200-300m
300 thru 400=4 300-400m
....
end

save as alt_class.txt

r.reclass input=old_rast_map output=new_rast_map < alt_class.txt

r.stats new_rast_map -c

Note that you could have also done something similar with

r.report map=old_rast_map units=k nsteps=

playing around with nsteps to get the same ranges. But r.reclass + r.stats/r.report gives you more precise control of your classes.

Moritz

Dear Moritz and all

Thank you useful and kind advice.
Sorry, please give advice to me a little more.

I tried the re-classification by using r.reclass method in the raster map of the
probability distribution.

An initial probability distribution is as follows:

|MAP: (untitled) (maxent_v2 in PERMANENT) |
|-----------------------------------------------------|
| Category Information | cell| square |
| #|description | count|kilometers|
|------------------------------------------------------|
| 0-0.003801|from to . . . . . . . . .. . . . . . . | 25890| 52,649.00|
|0.003801-0.007602|from to . . . . . . . . . .. . . . . . | 4738| 9625.82|
.......
.......
|0.954007-0.957808|from to . . . . . . . . . . . . . . . . | 1| 1.97|
| 0.965409-0.96921|from to . . . . . . . . . . . . . . . . | 1| 1.94 |
| *|no data. . . . . . . . . . . . .. . . . . |134527|272,251.90|

I want to classify it at 0.1 intervals. So I wrote text files as follows:
-----------
0.0 thru 0.1=0 A
0.1 thru 0.2=2 B
0.3 thru 0.4=3 C
0.4 thru 0.5=4 D
....
0.9 thru 1.0=10 J
end
-----------

then, I saved as probability_class.txt

r.reclass input=old_rast_map output=new_rast_map < probability_class.txt

then, following massage printed out on display:
-----
0.500000 rounded up to 0
0.600000 rounded up to 0
..........
1.400000 rounded up to 1
1.500000 rounded up to 1
-----

|-----------------------------------------------------------------------------|
|MAP: Reclass of maxent_v2 in PERMANENT (re_maxent in PERMANENT) |
|-----------------------------------------------------------------------------|
| Category Information | cell| square |
| #|description | count|kilometers|
|-----------------------------------------------------------------------------|
| 5| . . . . . . . . . . . . . . . . . . . . . . . . . . . .| 39215| 79,669.75|
|10| . . . . . . . . . . . . . . . . . . . . . . . . . . . .| 698| 1397.98|
| *|no data. . . . . . . . . . . . . . . . . . . . . . . . .|134527|272,251.90|

Why ? What's happened ?
I do not understand the cause not appropriately classified.

Best regard:

Yasuo shimada

Moritz Lennert <mlennert@club.worldonline.be>‚³‚ñF

On 16/12/08 14:40, SGW00412@nifty.com wrote:
> Dear Moritz:
>
> I wish to express my gratitude for your valuable advice. Thank you.
> It succeeded when having tried as follows:
>
> 0 thru 100=1 0-100m
> 100 thru 200=2 100-200m
> 200 thru 300=3 200-300m
> 300 thru 400=4 300-400m
> ....
> end
>
> save as alt_class.txt
>
> r.reclass input=old_rast_map output=new_rast_map < alt_class.txt
>
> r.stats new_rast_map -c

Note that you could have also done something similar with

r.report map=old_rast_map units=k nsteps=

playing around with nsteps to get the same ranges. But r.reclass +
r.stats/r.report gives you more precise control of your classes.

Moritz

SGW00412@nifty.com wrote:

Thank you useful and kind advice.
Sorry, please give advice to me a little more.

I tried the re-classification by using r.reclass method in the raster map of the
probability distribution.

I want to classify it at 0.1 intervals. So I wrote text files as follows:
-----------
0.0 thru 0.1=0 A
0.1 thru 0.2=2 B
0.3 thru 0.4=3 C
0.4 thru 0.5=4 D
....
0.9 thru 1.0=10 J
end
-----------

then, I saved as probability_class.txt

r.reclass input=old_rast_map output=new_rast_map < probability_class.txt

then, following massage printed out on display:
-----
0.500000 rounded up to 0
0.600000 rounded up to 0

Why ? What's happened ?
I do not understand the cause not appropriately classified.

Reclass maps only work for integers (they are implemented by looking
up the original cell values in an array, and you can't use
floating-point values as array indices).

You can use r.recode to generate a new map using a piecewise-linear
mapping. The category labels need to be set separately using
r.category.

Alternatively, if the intervals are equally spaced, you could generate
an integer version by scaling, e.g.:

  r.mapcalc 'newmap = int(oldmap * 10)'

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

Dear Glynn:

thank you good advice.

Reclass maps only work for integers

I see, I understood the cause from your advice.

Alternatively, if the intervals are equally spaced, you could generate
an integer version by scaling, e.g.:

  r.mapcalc 'newmap = int(oldmap * 10)'

r.mapcalc has a wonderful function, I think.

Okey,it's a nice method. I'll try again.

Thank you.

Yasuo SHIMADA
--

SGW00412@nifty.com wrote:

> Thank you useful and kind advice.
> Sorry, please give advice to me a little more.
>
> I tried the re-classification by using r.reclass method in the raster map of the
> probability distribution.

> I want to classify it at 0.1 intervals. So I wrote text files as follows:
> -----------
> 0.0 thru 0.1=0 A
> 0.1 thru 0.2=2 B
> 0.3 thru 0.4=3 C
> 0.4 thru 0.5=4 D
> ....
> 0.9 thru 1.0=10 J
> end
> -----------
>
> then, I saved as probability_class.txt
>
> r.reclass input=old_rast_map output=new_rast_map < probability_class.txt
>
> then, following massage printed out on display:
> -----
> 0.500000 rounded up to 0
> 0.600000 rounded up to 0

> Why ? What's happened ?
> I do not understand the cause not appropriately classified.

Reclass maps only work for integers (they are implemented by looking
up the original cell values in an array, and you can't use
floating-point values as array indices).

You can use r.recode to generate a new map using a piecewise-linear
mapping. The category labels need to be set separately using
r.category.

Alternatively, if the intervals are equally spaced, you could generate
an integer version by scaling, e.g.:

  r.mapcalc 'newmap = int(oldmap * 10)'