#' Extract Variable
#'
#' Extract specified variable from netCDF. Suggested use for filling template rasters
#' @param nc_path Path to netCDF file.
#' @param name Name of variable to extract.
#' @export
#' @return \code{raster} object
#' @examples
#' getVariable(nc_path = '.../smos.nc', name = 'Soil_Moisture')
getVariable <- function(nc_path,
name){
# open connection to netcdf
nc <- ncdf4::nc_open(nc_path)
# get lat, lon, and values and place into list
z = ncdf4::ncvar_get(nc, name)
# close connection to netcdf
ncdf4::nc_close(nc)
# return
return(z)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.