data(loaloa)
plot(loaloa)
# elevation
data(elevationLoa)
plot(elevationLoa, col=terrain.colors(100))
points(loaloa)
# vegetation index
data(eviLoa)
plot(eviLoa)
points(loaloa)
data(tempLoa)
plot(tempLoa)
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)
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