# How to find Entropy in land use (Voronoi polygons)?

I have a shapefile of land use in Montreal. It is composed of polygons. There are seven land uses: Residential, Commercial, Industrial, Waterbody, Parks, Open Area and Government. I need to find Entropy from this layer. Can anyone suggest how to do that? I am using Arcmap 10.1

-
How are you defining entropy? – Kirk Kuykendall Jul 18 '13 at 19:41

I would imagine that the easiest way would be to convert the polygons to a raster and then calculate entropy within a NxN moving window. Since you have only seven landcover types you can do this manually but it will be arduous.

Entropy is calculated as -sum(Pi*ln(Pi)) where; Pi is the probability of each landcover. In this case "probability" is referring to proportion of the class in relation to all the other classes. To calculate this you will need a raster for each class that represents the proportion of that class within the specified window. You would then apply a raster algebra statement to calculate entropy (H).

H = -1*( (lc1 * Ln(lc1) + (lc2 * Ln(lc2) + ...)

The expected maximized entropy is where a window is equally split between all classes or Ln(m) where; m is number of classes. You can get tricky with this method and test variable scales (window sizes).

In R parlance the function is such (and can easily be translated to Python):

``````  entropy <- function(x) {
p=vector()
if ( length(unique(x)) <= 1) { return(0) }
nv <- length(unique(x))
for( i in unique(x) ) {
p <- append(p, ( length(x[x == i]) / nv * log(length(x[x == i]) / nv) ) )
}
return( -sum(p) )
}
``````
-
Thank you very much – beginagain Jul 18 '13 at 20:15
+1. Here is a clearer, more efficient, and more flexible `R` solution: `entropy <- function(x, ...) { f <- tabulate(x); n <- sum(f); return(log(n, ...) - f %*% log(f, ...) / n) }`. An example of its use is `entropy(1:8, base=2)`. One ramification of this solution is that `tabulate` effectively produces the counts in the value attribute table for the land class raster, exhibiting the entropy calculation as a rather simple database summary operation, which can be hugely faster than processing a lot of separate rasters. – whuber Jul 18 '13 at 20:58
@whuber, Cool. This function is actually passed to the focal function in raster so, does not operate on multiple rasters. – Jeffrey Evans Jul 18 '13 at 21:52
The point is that it does not need to operate on multiple rasters. The shapefile is converted to a single raster containing factors for each polygon identifier. – whuber Jul 19 '13 at 13:10