# SHANNON INDEX AND MUCH MORE

Malcolm Williamson malcolm at cast.uark.edu
Tue Oct 1 15:36:05 EDT 1996

```On Tue, 1 Oct 1996, giovanna wrote:

> Good day to everybody,
>  I am an Enviromental Engineering student and I am working with Grassland
> for my thesis. My aim is to use Grassland to build Habitat
>
> Suitability Maps and to create (using Tcl/Tk) an user-friendly interface for
> people (as biologists) interested in creating Habitat
>
> Suitability Indexes but without GIS experience.
> Actually I have two problems and I would be happy if somebody can help me.
>
> 1)  I need to calculate SHANNON DIVERSITY INDEX which is defined as:
> H=-summation(pi*ln pi)  ;
>    i=1,2,...,n  ;
>    n=number of categories ;
>       pi=number of category i cells / number of cells in the neighborhood
> (ex: 9 if we  consider 3*3 neighborhood).
> This index infact is not calculated by r.neighbors function. IF  at least
> r.neighbors function calculates the number of cells which have
>
> category i in the neighbohood, then Shannon diversity index could be
> calculated easily with r.mapcalc. Anyway this possibility does
>
> not exist.

This can be done directly in r.mapcalc, using the [row,column] format.
The following would be an example of a 3x3 averaging filter:

mapcalc> average=(map[-1,-1] + map[-1,0] + map[-1,1] + map[0,-1] +
map[0,0] + map[0,1] + map[1,-1] + map[1,0] + map[1,1] )/9>

I'd definitely recommend getting the r.mapcalc tutorial off of the moon.

> 2) I would need to create a raster map where each cell has the value of the
> AREA of the clump which it belongs to, and another where
>

Use r.stats to output the category and area (in cells) to a file. Use awk
or perl to massage the area value to the units that you want, and add an
equal sign between the category and area, creating a reclass rules file.
Use the reclass rules with r.reclass.

> the value of each cell is the PERIMETER of the clump. I did not succed in
> doing that.
>
> 3)  How can I import maps whose projection is Gauss-Boaga?
>
> Did anybody develop GRASS functions which can be useful for my purposes?
> How can I import them in Grassland?
> ANY help is welcomed, thanks.
>
> I am also desperately looking for Grass Tutorials about functions r.binfer
> (this is the most important to me), r.mapcalc, r.cost, r.combine, r.infer,
> r.neighbors.
> Could you help me?
>
> Thank you very much,
> Regards
>
> Giovanna Ranci Ortigosa
> student of Enviromental Engineering
> Politecnico di Milano, Italy
> e-mail: ranci at quercia.elet.polimi.it
>
>
> Giovanna Ranci Ortigosa
> student of Enviromental Engineering
> Politecnico di Milano
> Italy
>
> e_mail: ranci at quercia.elet.polimi.it
>
>
--
Malcolm D. Williamson - GIS Specialist           E-mail: malcolm at cast.uark.edu
Center for Advanced Spatial Technologies      Telephone: (501) 575-6159
Ozark Rm. 12                                        Fax: (501) 575-5218
University of Arkansas
Fayetteville, AR 72701

```