Skip to contents

This function extracts climate data from the CORDEX-BC dataset and organizes it into a nested list.

Usage

load_netcdf_weather(dir_path, location)

Arguments

dir_path

Character, path to the CORDEX-BC folder (e.g., "climate/CORDEX-BC"). NetCDF data to be recognized by the function should be saved with these specific file names:

  • "prec.nc" for precipitation,

  • "relHum.nc" for relative humidity,

  • "solarRad.nc" for solar radiation,

  • "Tmax.nc" for maximum daily temperature,

  • "Tmin.nc" for minimum daily temperature,

  • "windSpeed.nc" for wind speed. Ensure that the NetCDF files are correctly named and stored in the specified directory for the function to recognize them.'

location

Character or list. If character, provide the path to the catchment boundary file (e.g., "GIS/basin.shp"). If a list, use the nested list with dataframes. The nested structure is same as prepared by using load_template or load_swat_weather functions.

Value

Nested list. The first nesting level is for RCP, the second for RCM model numbers, and the rest follows the structure of meteo_lst. Nested structure: meteo_lst -> data -> Station ID -> Parameter -> Dataframe (DATE, PARAMETER), meteo_lst -> stations -> Dataframe (ID, Name, Elevation, Source, geometry, Long, Lat). This nested list structure can be used with other package functions (e.g., plot_weather(result$rcp26$"1", "PCP", "month", "sum")).

Examples

if (FALSE) {
  # Specify the path to the catchment boundary file
  basin_path <- system.file("extdata", "GIS/basin.shp", package = "SWATprepR") 
  
  # Specify the path to the CORDEX-BC data
  data_path <- "climate/CORDEX-BC"
  
  # Extract and organize climate data
  result <- load_netcdf_weather(data_path, basin_path)
}