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
Answer
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) )
}
No comments:
Post a Comment