# NOT RUN {
library(raster)
library(sp)
data(africa)
names(africa)
Endm <- weighted_endemism(africa$comm)
C <- coldspots(Endm) # coldspots
H <- hotspots(Endm) # hotspots
## Merge endemism values to shapefile of grid cells.
DF <- data.frame(grids=names(C), cold=C, hot=H)
m <- merge(africa$polys, DF, by = "grids", all = TRUE)
plot(africa$polys, border = "grey", col = "lightgrey",
main = "Weighted Endemism Hotspots and Coldspots")
plot(m[(m@data$cold == 1), ], col = "blue", add = TRUE, border = NA)
plot(m[(m@data$hot == 1), ], col = "red", add = TRUE, border = NA)
legend("bottomleft", fill = c("blue", "red", "yellow", "green"),
legend = c("coldspots", "hotspots"), bty = "n", inset = .092)
# }
Run the code above in your browser using DataLab