View source: R/get_external_data.R
get_external_data | R Documentation |
Downloads a ZIP file with example rasters and shapefiles from GitHub releases and optionally loads a specific file.
get_external_data(filename = NULL, path = tempdir(), load = FALSE)
filename |
Optional. The name of the file to return (after extraction). |
path |
Local directory to download and extract files. Default is a temp folder. |
load |
Logical. If TRUE, returns a loaded object (RasterLayer for .tif, sf for .shp). Default is FALSE. |
File path or loaded object if 'load = TRUE'.
# Download example data and list contents
data_dir <- get_external_data(path = tempdir())
list.files(data_dir)
# Load a specific raster file (.tif)
pre_fire <- get_external_data("NBRpre.tif", path = tempdir(), load = TRUE)
print(pre_fire)
# Load a specific shapefile (.shp)
shape_data <- get_external_data("shapefile_reference.shp", path = tempdir(), load = TRUE)
print(shape_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.