knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
You can install gshhg from github with:
# install.packages("devtools") devtools::install_github("jsta/gshhg")
library(gshhg)
# Download raw data gshhg_get(version = "2.3.7")
library(sf) # intermediate dt_i <- st_read( list.files(file.path(gshhg:::cache_path(), "2.3.7", "GSHHS_shp", "i"), pattern = "L1.shp", full.names = TRUE, include.dirs = TRUE)) # low dt_l <- st_read( list.files(file.path(gshhg:::cache_path(), "2.3.7", "GSHHS_shp", "l"), pattern = "L1.shp", full.names = TRUE, include.dirs = TRUE)) # crude dt_c <- st_read( list.files(file.path(gshhg:::cache_path(), "2.3.7", "GSHHS_shp", "c"), pattern = "L1.shp", full.names = TRUE, include.dirs = TRUE)) bb <- st_sfc(st_polygon(list(rbind(c(-6.46, 49.696), c(-7.2, 58.768), c(1.9336, 58.7909), c(2.417, 50.18), c(-6.46, 49.696)))), crs = 4326) get_within <- function(dt, bb){ dt[sapply(st_within(dt, bb), function(x) length(x) > 0),] } dt_britain <- lapply(list(dt_i, dt_l, dt_c), function(x) get_within(x, bb)) par(mfrow = c(1, 3)) lapply(dt_britain, function(x) plot(st_geometry(x)))
lake_f <- st_read( list.files(file.path(gshhg:::cache_path(), "2.3.7", "GSHHS_shp", "f"), pattern = "L2.shp", full.names = TRUE, include.dirs = TRUE)) mapview::mapview(lake_f[which.min(lake_f$area),])
m <- mapview::mapview(lake_f[which.min(lake_f$area),]) mapview::mapshot(m, file = "smallest_lake.png")
See http://www.soest.hawaii.edu/pwessel/gshhg/
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.