if (FALSE) {
if (require(leaflet) && (packageVersion("leaflet") > "2.1.1")) {
v <- vect(system.file("ex/lux.shp", package="terra"))
p <- spatSample(as.polygons(v, ext=T), 30)
values(p) = data.frame(id=11:40, name=letters[1:30])
m <- plet(v, "NAME_1", tiles="", border="blue")
m <- points(m, p, col="red", cex=2, popup=T)
lines(m, v, lwd=1, col="white")
plet(v, "NAME_1", split=TRUE, alpha=.2) |>
points(p, col="gray", cex=2, popup=TRUE,
clusterOptions = markerClusterOptions())
s <- svc(v, p)
names(s) <- c("the polys", "set of points")
plet(s, col=c("red", "blue"), lwd=1)
r <- rast(system.file("ex/elev.tif", package="terra"))
plet(r, main="Hi\nthere") |> lines(v, lwd=1)
plet(r, tiles="Streets") |> lines(v, lwd=2, col="blue")
x <- c(r, 50*classify(r, 5))
names(x) <- c("first", "second")
# each their own legend
plet(x, 1:2, tiles="Streets", collapse=FALSE) |> lines(v, lwd=2, col="blue")
# shared legend
plet(x, 1:2, tiles="Streets", shared=TRUE, collapse=FALSE) |> lines(v, lwd=2, col="blue")
}}
Run the code above in your browser using DataLab