Learn R Programming

rIACI (version 1.0.0)

csv_to_netcdf: CSV to NetCDF Function

Description

Merges CSV files in a specified directory into a single NetCDF file, completing the grid by filling missing values.

Usage

csv_to_netcdf(csv_dir, output_file, freq)

Value

None. The NetCDF file is saved to the specified location.

Arguments

csv_dir

Character. Directory containing CSV files, each file representing a single latitude-longitude point. The filename format should be 'lat_lon.csv'.

output_file

Character. Path to the output NetCDF file.

freq

Character. Frequency of the data, either `'monthly'` or `'seasonal'`. - `'monthly'` data uses date format `'YYYY-MM'`. - `'seasonal'` data uses date format like `'YYYY-SSS'` (e.g., `'1961-DJF'`).

Examples

Run this code
if (FALSE) {
# Example usage of csv_to_netcdf
csv_directory <- "/path/to/csv_files"
output_netcdf_file <- "/path/to/output_file.nc"
csv_to_netcdf(csv_dir = csv_directory, output_file = output_netcdf_file, freq = "monthly")
}

Run the code above in your browser using DataLab