gbm.basemap | R Documentation |
Downloads unzips crops & saves NOAAs global coastline shapefiles to user-set box. Use for 'shape' in gbm.map. If downloading in RStudio uncheck "Use secure download method for HTTP" in Tools > Global Options > Packages. Simon Dedman, 2015/6 simondedman@gmail.com GitHub.com/SimonDedman/gbm.auto
gbm.basemap(
bounds = NULL,
grids = NULL,
gridslat = NULL,
gridslon = NULL,
getzip = TRUE,
zipvers = "2.3.7",
savedir = tempdir(),
savename = "Crop_Map",
res = "CALC",
extrabounds = FALSE
)
bounds |
Region to crop to: c(xmin,xmax,ymin,ymax). |
grids |
If bounds unspecified, name your grids database here. |
gridslat |
If bounds unspecified, specify which column in grids is latitude. |
gridslon |
If bounds unspecified, specify which column in grids is longitude. |
getzip |
Download & unpack GSHHS data to WD? "TRUE" else absolute/relative reference to GSHHS_shp folder, including that folder. |
zipvers |
GSHHS version, in case it updates. Please email developer (SD) if this is incorrect. |
savedir |
Save outputs to a temporary directory (default) else change to current directory e.g. "/home/me/folder". Do not use getwd() here. |
savename |
Shapefile save-name, no shp extension, default is "Crop_Map" |
res |
Resolution, 1:5 (low:high) OR c,l,i,h,f (coarse, low, intermediate, high, full) or "CALC" to calculate based on bounds. Choose one. |
extrabounds |
Grow bounds 16pct each direction to expand rectangular datasets basemaps over the entire square area created by basemap in mapplots. |
errors and their origins:
Error in setwd(getzip) : cannot change working directory If you've specified the location of the local GSHHS_shp folder, ensure you're in the correct directory relative to it. This error means it looked for the folder and couldn't find it.
subscript out of bounds: can't crop world map to your bounds. Check lat/lon are the right way around: check gridslat and gridslon point to the correct columns for lat and lon in grids, and those columns named (something like) lat and lon, ARE ACTUALLY the latitudes and longitudes, and not the wrong way around.
If your download is timing out use options(timeout = 240).
Error in if (scope >= 160) res <- "c" : missing value where TRUE/FALSE needed. Check gridslat and gridslon are indexing the correct columns in grids.
basemap coastline file for gbm.map in gbm.auto. "cropshp" SpatialPolygonsDataFrame in in local environment & user-named files in "CroppedMap" folder. Load later with maptools function: MyMap <- sf::st_read(dsn = "./CroppedMap/Crop_Map.shp", layer = "Crop_Map, quiet = TRUE)
Simon Dedman, simondedman@gmail.com
# Not run: downloads and saves external data.
data(samples)
mybounds <- c(range(samples[,3]),range(samples[,2]))
gbm.basemap(bounds = mybounds, getzip = "./GSHHS_shp/",
savename = "My_Crop_Map", res = "f")
# In this example GSHHS folder already downloaded to the working directory
# hence I pointed getzip at that rather than having it download the zip again
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.