data("loaloa")
plot(loaloa, main="loaloa villages")
# elevation
data("elevationLoa")
plot(elevationLoa, col=terrain.colors(100), main="elevation")
points(loaloa)
# vegetation index
data("eviLoa")
plot(eviLoa, main="evi")
points(loaloa)
data("tempLoa")
plot(tempLoa, main="temperature")
points(loaloa)
data("ltLoa")
# land type, a categorical variable
commonValues = sort(table(values(ltLoa)),decreasing=TRUE)[1:7]
commonValues=commonValues[!names(commonValues)==0]
thelevels = levels(ltLoa)[[1]]$ID
thebreaks = c(-0.5, 0.5+thelevels)
thecol = rep(NA, length(thelevels))
names(thecol) = as.character(thelevels)
thecol[names(commonValues)] = rainbow(length(commonValues))
plot(ltLoa, breaks=thebreaks, col=thecol,legend=FALSE, main="land type")
legend("bottomleft",fill=thecol[names(commonValues)],
legend=levels(ltLoa)[[1]][
match(as.integer(names(commonValues)),
levels(ltLoa)[[1]]$ID),
"Category"],
bty='n'
)
points(loaloa)
Run the code above in your browser using DataLab