library(knitr) knitr::opts_chunk$set(echo = TRUE, cache = TRUE) root <- rprojroot::find_rstudio_root_file()
library(raster)
natearth <- brick(unzip("C:/Users/FRS/Dropbox/GIS.layers/NaturalEarth/CrossBlended_Hypso_ShadedRelief_50m.zip", exdir = tempdir())[4]) ne <- crop(natearth, extent(c(-175, -15, -60, 90))) ne.redux <- aggregate(ne, fact = 8)
data(regions) #plot(regions, add = TRUE, border = "black")
locs <- as.data.frame(readr::read_csv(paste0(root, "/data/locs_30m.csv"))) coordinates(locs) <- c("longitude", "latitude") projection(locs) <- CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0") #plot(locs, add = TRUE) # rSDM::occmap(locs[locs$species == "macloviana", ]) # rSDM::occmap(locs[locs$species == "maritima", ])
library(RColorBrewer) mypal <- brewer.pal(5, "Set1") pdf("figures/Fig1.pdf", paper = "a4") #svglite::svglite("manuscript/figures/Fig1.svg", width = 9, height = 11) plotRGB(ne.redux) plot(regions, add = TRUE, border = "dim gray", lwd = 2) #spp <- unique(locs$species) spp <- c("maritima", "microglochin", "canescens", "magellanica", "macloviana") for (i in 1:5) { points(locs[locs$species == spp[i], ], pch = 21, bg = mypal[i], col = "gray20", cex = 1) } legend(x = -160, y = 10, legend = spp, pt.bg = mypal, pch = 21, box.col = "white", title = "Carex species", bg = "white") dev.off()
library(ggplot2) library(mapr) occs <- locs[, c("species")] names(occs) <- "name" basemap <- map_ggmap(occs, zoom = 2, size = 2) basemap + xlim(-165, -22) + ylim(-50, 95)
devtools::session_info()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.