Skip to content

Instantly share code, notes, and snippets.

@Pakillo
Last active March 21, 2018 19:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pakillo/78c25233d72a87c69961a765393d91ff to your computer and use it in GitHub Desktop.
Save Pakillo/78c25233d72a87c69961a765393d91ff to your computer and use it in GitHub Desktop.
another reproducible map with Rstats
library(sf)
library(ggspatial)
library(ggthemes)
coast <- rnaturalearth::ne_coastline(scale = "small", returnclass = "sp")
forests <- st_read("data/forestmap/cfc_gen.shp")
forest.redux <- rmapshaper::ms_simplify(forests)
forest.redux.sp <- as(forest.redux, "Spatial")
# could also use geom_sf from ggplot2 on github
ggplot() + coord_map() +
geom_spatial(forest.redux.sp, show.legend = FALSE,
col = "gray 80", fill = "gray 80") +
geom_spatial(coast, col = "gray 40") +
theme_map() +
xlim(-170, 180) +
ylim(-55, 80) +
geom_point(data = coords, aes(x = lon, y = lat, fill = vegtype),
colour = "black", size = 5, shape = 21) +
theme(legend.title = element_blank(), legend.text = element_text(size = 12),
legend.position = c(0.05, 0.15))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment