# Calculating shannon diversity index from multiple rasters in ArcGIS raster calculator?

I'm a basic ArcGIS user with no experience in Python coding (but some experience in R). I have several rasters, each representing the density of a given variable. My goal is to apply the shannon diversity index to the rasters and produce a new raster showing the diversity of these variables.

The diversity formula is as such:

Is there a tool or plugin for this? I am familiar with raster calculator, but this equation seems a bit to complicated... eg, how to enter sigma and calculate the proportions?

I also found some Python code, but I have a feeling that it will be a substantial endeavour to open up a new type of code and to get this running. https://gist.github.com/audy/783125

Is Python code the only way to do this, or would this be easier in R?

I don't know if you have found something, but using grass-GIS you can try all function for landscape analysis.

For example, the r.li.shanon function can be useful for you! And a good point, you can connect Grass in R with the rgrass7 package !

In R it look like :

``````library(rgrass7)
library(raster)

# initialisation and the a nice dataset
initGRASS(gisBase = "/usr/lib/grass72", home = tempdir(),
gisDbase = "/home/user/grassDB/",
location = "Widou", mapset = "tests", override=TRUE)

execGRASS("r.li.shannon", parameters = list(input="forests", conf="movwindow7" out="forests_shannon_mov7"),
flags = c("overwrite"))
plot(reasRAST("forests_shannon_mov7")) ##plot image
``````