2.5 Basic map mapping
= world[world$continent == "Asia", ]
world_asia = st_union(world_asia)
asia plot(world["pop"], reset = FALSE)
plot(asia, add = TRUE, col = "red")
plot
concept is adding layer. It is good for quick vizualisation.
-> for more advanced mapping: tmap
But base plot is still a powerful tool:
plot(world["continent"], reset = FALSE)
= sqrt(world$pop) / 10000
cex = st_centroid(world, of_largest = TRUE) world_cents
## Warning: st_centroid assumes attributes are constant over geometries
plot(st_geometry(world_cents), add = TRUE, cex = cex)
expandBB
is quite good for simple context map:
= world[world$name_long == "India", ] # TODO discuss the subset
india plot(st_geometry(india), expandBB = c(0, 0.2, 0.1, 1), col = "gray", lwd = 3)
plot(st_geometry(world_asia), add = TRUE)