ck_from_netcdf: Read a netCDF File as a SpatRaster

View source: R/gridded.R

ck_from_netcdfR Documentation

Read a netCDF File as a SpatRaster

Description

Convenience wrapper that delegates to terra::rast(). Reads the file at path and returns a SpatRaster, optionally restricted to a single variable. terra and ncdf4 must be installed (both are listed in ⁠Suggests:⁠).

Usage

ck_from_netcdf(path, var = NULL)

Arguments

path

Character. Path to a netCDF file.

var

Character or NULL. Variable to extract. If NULL, the default behaviour of terra::rast() applies.

Value

A SpatRaster (one layer per time step in the netCDF file).

Examples

## Not run: 
  r <- ck_from_netcdf("tas_day.nc", var = "tas")
  terra::nlyr(r)  # number of daily layers

## End(Not run)

climatekit documentation built on May 9, 2026, 5:08 p.m.