subsetNC: Subset NetCDF files by x,y,time or variable

View source: R/subsetNC.R

subsetNCR Documentation

Subset NetCDF files by x,y,time or variable

Description

Subset a NetCDF file by a spatial extent (x,y), time or variable and output it as a raster stack

Usage

subsetNC(
  files,
  startdate = NA,
  enddate = NA,
  ext = "",
  varid = "",
  filename = "",
  format = "raster",
  overwrite = FALSE
)

Arguments

files

character. File path.

startdate

integer. Start year.

enddate

integer. End year.

ext

integer. Extent object.

varid

character. Variable that should be extracted.

filename

character. Output filename.

format

character. Output file type. See writeRaster for different Options. The default format is "raster".

overwrite

logical. Should file be overwritten or not.

Value

A numeric raster stack with the cropped NetCDF data.

Examples

files <- list.files(paste0(system.file(package="processNC"), "/extdata"), 
                    pattern="tas.*\\.nc", full.names=TRUE)
subsetNC(files, ext=c(8.5, 14, 47, 51), startdate=1990, enddate=1999)

RS-eco/processNC documentation built on Aug. 7, 2023, 8:12 a.m.