data(hessen)
# continuous variable between 0 and 1
data <- hessen$data[,1:3]
heights <- round(data[,1]/rowSums(data), digits = 1)
cols <- heat.colors(11)
names(cols) <- names(table(heights))
# boundary as sf
w <- sf::st_as_sf(hessen$boundary)
sf::st_crs(w) <- 4326
w <- sf::st_transform(w, 2397)
# points as sf
p <- sf::st_as_sf(hessen$villages, coords = c("longitude", "latitude"))
sf::st_crs(p) <- 4326
p <- sf::st_transform(p, 2397)
# plot map
plot(p, col = cols[as.character(heights)], border = NA, pch = 19)
plot(w, add = TRUE, border = "grey")
# add boundary
addContour(heights, points = p, window = w, crs = 2397, grid = 1000,
levels = c(0.25, 0.35, 0.45), col = "blue")
Run the code above in your browser using DataLab