ebv_read_shp {ebvcube} | R Documentation |
Read subset (shapefile) of one datacube of an EBV netCDF
Description
Read a subset of one or more layers from one datacube of the netCDF file. Subset definition by a shapefile.
Usage
ebv_read_shp(
filepath,
datacubepath = NULL,
entity = NULL,
timestep = 1,
shp,
outputpath = NULL,
touches = TRUE,
scenario = NULL,
metric = NULL,
overwrite = FALSE,
ignore_RAM = FALSE,
verbose = TRUE
)
Arguments
filepath |
Character. Path to the netCDF file. |
datacubepath |
Character. Optional. Default: NULL. Path to the datacube
(use |
entity |
Character or Integer. Default is NULL. If the structure is 3D, the entity argument is set to NULL. Else, a character string or single integer value must indicate the entity of the 4D structure of the EBV netCDFs. |
timestep |
Integer or character. Select one or several timestep(s). Either provide an integer value or list of values that refer(s) to the index of the timestep(s) (minimum value: 1) or provide a date or list of dates in ISO format, such as '2015-01-01'. |
shp |
Character. Path to the shapefile defining the subset. Ending needs to be *.shp. |
outputpath |
Character. Default: NULL, returns the data as a SpatRaster object in memory. Optional: set path to write subset as GeoTiff on disk. |
touches |
Logical. Default: TRUE, all pixels touched by the polygon(s) will be updated. Set to FALSE to only include pixels that are on the line render path or have center points inside the polygon(s). |
scenario |
Character or integer. Optional. Default: NULL. Define the
scenario you want to access. If the EBV netCDF has no scenarios, leave the
default value (NULL). You can use an integer value defining the scenario or
give the name of the scenario as a character string. To check the available
scenarios and their name or number (integer), use
|
metric |
Character or integer. Optional. Define the metric you want to
access. You can use an integer value defining the metric or give the name
of the scenario as a character string. To check the available metrics and
their name or number (integer), use |
overwrite |
Logical. Default: FALSE. Set to TRUE to overwrite the outputfile defined by 'outputpath'. |
ignore_RAM |
Logical. Default: FALSE. Checks if there is enough space in your memory to read the data. Can be switched off (set to TRUE). |
verbose |
Logical. Default: TRUE. Turn off additional prints by setting it to FALSE. |
Value
Returns a SpatRaster object if no output path is given. Otherwise the subset is written onto the disk and the ouput path is returned.
See Also
ebv_read_bb()
for subsetting via bounding box.
Examples
#set path to EBV netCDF
file <- system.file(file.path("extdata","martins_comcom_subset.nc"), package="ebvcube")
#get all datacubepaths of EBV netCDF
datacubes <- ebv_datacubepaths(file, verbose=FALSE)
#set path to shp file - cameroon country borders
shp_path <- system.file(file.path("extdata","cameroon.shp"), package="ebvcube")
#read subset - return SpatRaster
cSAR_cameroon <- ebv_read_shp(filepath = file, datacubepath = datacubes[1,1],
entity = 1, timestep = 1, shp = shp_path,
outputpath = NULL, ignore_RAM = TRUE)