[GRASS-user] edit category information?

Greetings all,

I am looking to edit a raster map's category information. The map in question has the following categories:

|-----------------------------------------------------------------------------|
| Category Information |
| #|description |
|-----------------------------------------------------------------------------|
| 0| |
|100| |
|120| |
|180| |
|260| |
|380| |
|400| |
|500| |
|600| |
|700| |
|800| |
|900| |
|990| |
|999| |
+-----------------------------------------------------------------------------+

I would like to add category names (Oak, Pine, Spruce, etc...) to these numbers.I have been looking around for a way to do it (r.reclass?, r.recode?). I'm just not sure what is the "approved" approach here. Any suggestions?

Thanks,

Kirk

Hi,
try to use r.reclass with the same categories but adding the labels.
See http://www.grass.itc.it/grass63/manuals/html63_user/r.reclass.html

Ciao
Leonardo

Kirk Wythers ha scritto:

Greetings all,

I am looking to edit a raster map's category information. The map in
question has the following categories:

|-----------------------------------------------------------------------------|

| Category
Information |
|
#|description
|
|-----------------------------------------------------------------------------|

|
0|
   |
|100|
     |
|120|
     |
|180|
     |
|260|
     |
|380|
     |
|400|
     |
|500|
     |
|600|
     |
|700|
     |
|800|
     |
|900|
     |
|990|
     |
|999|
     |
+-----------------------------------------------------------------------------+

I would like to add category names (Oak, Pine, Spruce, etc...) to
these numbers.I have been looking around for a way to do it
(r.reclass?, r.recode?). I'm just not sure what is the "approved"
approach here. Any suggestions?

Thanks,

Kirk

_______________________________________________
grassuser mailing list
grassuser@grass.itc.it
http://grass.itc.it/mailman/listinfo/grassuser

Kirk Wythers wrote:

I am looking to edit a raster map's category information.

..

I would like to add category names (Oak, Pine, Spruce, etc...) to
these numbers.I have been looking around for a way to do it
(r.reclass?, r.recode?). I'm just not sure what is the "approved"
approach here. Any suggestions?

r.support will do it in interactive mode from the command line. That
uses the funny old esc-enter interface, but it works.

or edit the $MAPSET/cats/$MAPNAME file by hand, it's a simple text file.
Use one of the categorical spearfish maps as an example.

Hamish

Hamish wrote on 09/06/2007 12:45 PM:

Kirk Wythers wrote:
  

I am looking to edit a raster map's category information.
    

..
  

I would like to add category names (Oak, Pine, Spruce, etc...) to
these numbers.I have been looking around for a way to do it
(r.reclass?, r.recode?). I'm just not sure what is the "approved"
approach here. Any suggestions?
    
r.support will do it in interactive mode from the command line. That
uses the funny old esc-enter interface, but it works.

or edit the $MAPSET/cats/$MAPNAME file by hand, it's a simple text file.
Use one of the categorical spearfish maps as an example.
  

How complicated would it be to develop an optional tcl frontend (like
g.mapsets has) for
r.support/cats editing? The format isn't that complicated (4 header
lines, then ':' separated):

cat nc_spm_06/PERMANENT/cats/landuse96_28m
# 24 categories
South-West Wake county: NC Land Use 1996 clipped

0.00 0.00 0.00 0.00
0:not classified
1:High Intensity Developed
2:Low Intensity Developed
[...]

Markus

------------------
ITC -> dall'1 marzo 2007 Fondazione Bruno Kessler
ITC -> since 1 March 2007 Fondazione Bruno Kessler
------------------

Kirk,

You can use r.reclass. If you want to make the result an independent file
(not just a virtual reclass), you can use r.mapcalc to write it out.

r.support might also work.

Michael

On 9/5/07 10:32 AM, "Kirk Wythers" <kwythers@umn.edu> wrote:

Greetings all,

I am looking to edit a raster map's category information. The map in
question has the following categories:

|-----------------------------------------------------------------------
------|
| Category
Information |
| #|
description
  |
|-----------------------------------------------------------------------
------|
|
0|
    |
|
100|
      |
|
120|
      |
|
180|
      |
|
260|
      |
|
380|
      |
|
400|
      |
|
500|
      |
|
600|
      |
|
700|
      |
|
800|
      |
|
900|
      |
|
990|
      |
|
999|
      |
+-----------------------------------------------------------------------
------+

I would like to add category names (Oak, Pine, Spruce, etc...) to
these numbers.I have been looking around for a way to do it
(r.reclass?, r.recode?). I'm just not sure what is the "approved"
approach here. Any suggestions?

Thanks,

Kirk

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

On 9/6/07 4:57 AM, "Markus Neteler" <neteler@itc.it> wrote:

Hamish wrote on 09/06/2007 12:45 PM:

Kirk Wythers wrote:
  

I am looking to edit a raster map's category information.
    

..
  

I would like to add category names (Oak, Pine, Spruce, etc...) to
these numbers.I have been looking around for a way to do it
(r.reclass?, r.recode?). I'm just not sure what is the "approved"
approach here. Any suggestions?
    
r.support will do it in interactive mode from the command line. That
uses the funny old esc-enter interface, but it works.

or edit the $MAPSET/cats/$MAPNAME file by hand, it's a simple text file.
Use one of the categorical spearfish maps as an example.
  

How complicated would it be to develop an optional tcl frontend (like
g.mapsets has) for
r.support/cats editing? The format isn't that complicated (4 header
lines, then ':' separated):

cat nc_spm_06/PERMANENT/cats/landuse96_28m
# 24 categories
South-West Wake county: NC Land Use 1996 clipped

0.00 0.00 0.00 0.00
0:not classified
1:High Intensity Developed
2:Low Intensity Developed
[...]

Markus

The main thing needed first is a way to get category information INTO
r.support from a file and/or stdin. Basically, it needs a "rules" file
option like has been added to r.reclass and r.recode. If it had the same
syntax as r.reclass, it would simplify things from a user point of view. We
could then just use the same simple 'rules' interface to change categories
and labels on an existing map as we do to reclassify a map. e.g....

0 = 0 not classified
1 thru 2 = 1 developed

Michael

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Michael Barton wrote:

The main thing needed first is a way to get category information INTO
r.support from a file and/or stdin. Basically, it needs a "rules" file
option like has been added to r.reclass and r.recode. If it had the same
syntax as r.reclass, it would simplify things from a user point of
view. We could then just use the same simple 'rules' interface to
change categories and labels on an existing map as we do to reclassify
a map. e.g....

0 = 0 not classified
1 thru 2 = 1 developed

You can't add that to r.support as the module is too general, it's not
just for cats.

it would either need two options:
rules=<<data>>
and
what_the_input_data_is=cats

or a bunch of flags to control that.

Seems messy- Probably better to have a new r.support.cats module to take
care of that? Writing the cats file is so simple I don't know if it
really needs its own C module, or if you can just write out the file
directly from the GUI.

the cats file format is detailed in sections 5.4 and! 12.11.9.2 of the
GRASS 5.0 Programmer's Manual. (I'm not sure where it is in the GRASS 6
prog manual) Note there are two different map titles, one from the cats
file, the other from the hist file (in r.info "title_cats (title_hist)")

Cat labels can be dynamic, see
  https://intevation.de/rt/webrt?serial_num=2437

e.g. 'r.neighbors method=diversity' creates a dynamic cats/ file.

Hamish

On 9/6/07 8:40 PM, "Hamish" <hamish_nospam@yahoo.com> wrote:

Michael Barton wrote:

The main thing needed first is a way to get category information INTO
r.support from a file and/or stdin. Basically, it needs a "rules" file
option like has been added to r.reclass and r.recode. If it had the same
syntax as r.reclass, it would simplify things from a user point of
view. We could then just use the same simple 'rules' interface to
change categories and labels on an existing map as we do to reclassify
a map. e.g....

0 = 0 not classified
1 thru 2 = 1 developed

You can't add that to r.support as the module is too general, it's not
just for cats.

All the other stuff except for cats already seems to have an option to
enter. This is why I suggested it.

it would either need two options:
rules=<<data>>
and
what_the_input_data_is=cats

Not sure that I understand this. Is this something beyond what already can
be entered (I mean from the command line or GUI and not just from the old
interactive terminal app)?

or a bunch of flags to control that.

Seems messy- Probably better to have a new r.support.cats module to take
care of that? Writing the cats file is so simple I don't know if it
really needs its own C module, or if you can just write out the file
directly from the GUI.

the cats file format is detailed in sections 5.4 and! 12.11.9.2 of the
GRASS 5.0 Programmer's Manual. (I'm not sure where it is in the GRASS 6
prog manual) Note there are two different map titles, one from the cats
file, the other from the hist file (in r.info "title_cats (title_hist)")

Seems to me that these should be the same. Any reason that they should be
different?

Cat labels can be dynamic, see
  https://intevation.de/rt/webrt?serial_num=2437

e.g. 'r.neighbors method=diversity' creates a dynamic cats/ file.

I read the reference but I still don't really understand what this means.

Michael

Hamish

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Hamish wrote:

Seems messy- Probably better to have a new r.support.cats module to take
care of that? Writing the cats file is so simple I don't know if it
really needs its own C module, or if you can just write out the file
directly from the GUI.

Regardless of how simple the format is, there should be a C module to
do this. If the format were ever changed, the only code which should
need to be changed is lib/gis/cats.c.

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