The goal of cft is to provide easy climate data access (MACA v2) to support climate scenario planning. This package allows you to:

  1. Quickly acquire climate data subsets for a spatial region of interest
  2. Summarize climate data at daily timesteps, and compute derived quantities
  3. Contrast reference and target time periods to understand differences in climate over time, and
  4. Easily work with climate data, without having to worry about the details of how it is stored or formatted


Install the development version of cft from GitHub with:

# install.packages("remotes")

Quickstart guide

To get daily maximum air temperature data for an area of interest, you can use the cftdata() function:

First define an area of interest. This should be a Spatial* object. In this case we’ll load a file distributed with this package, but you could read a local shapefile etc.

aoi <- rgdal::readOGR(system.file("extdata", "windcave.geojson", package = "cft"))
#> OGR data source with driver: GeoJSON 
#> Source: "/home/max/R/x86_64-pc-linux-gnu-library/4.0/cft/extdata/windcave.geojson", layer: "windcave"
#> with 1 features
#> It has 19 fields

Then, download some data using the cftdata() function.

d <- cftdata(aoi = aoi, area_name = "windcave", parameters = "tasmax", 
             years = c(2003, 2007), models = "CCSM4", scenarios = "rcp85")
#> [1] "Building area of interest grid..."
#> [1] "Retrieving climate data for windcave"
#> [1] "Saving local files to /tmp/RtmprzFNKx/windcave"

This gives you a data frame with paths to local climate data files:

#> # A tibble: 1 x 13
#>   local_file local_path model parameter rcp   ensemble year1 year2 area_name
#>   <chr>      <chr>      <chr> <chr>     <chr> <chr>    <dbl> <dbl> <chr>    
#> 1 tasmax_wi… /tmp/Rtmp… CCSM4 tasmax    rcp85 r6i1p1    2003  2007 windcave 
#> # … with 4 more variables: units <chr>, full_varname <chr>,
#> #   internal_varname <chr>, parameter_long <chr>

And, you can also summarize the daily data by computing a spatial average over the region of interest:

df <- cft_df(d, ncores = 2)
#> Computing spatial averages...
#> Generating climate data.frame...
#> # A tibble: 1,826 x 6
#>    rcp   date       model ensemble area_name tasmax
#>    <chr> <date>     <chr> <chr>    <chr>      <dbl>
#>  1 rcp85 2003-01-01 CCSM4 r6i1p1   windcave    265.
#>  2 rcp85 2003-01-02 CCSM4 r6i1p1   windcave    263.
#>  3 rcp85 2003-01-03 CCSM4 r6i1p1   windcave    268.
#>  4 rcp85 2003-01-04 CCSM4 r6i1p1   windcave    270.
#>  5 rcp85 2003-01-05 CCSM4 r6i1p1   windcave    269.
#>  6 rcp85 2003-01-06 CCSM4 r6i1p1   windcave    274.
#>  7 rcp85 2003-01-07 CCSM4 r6i1p1   windcave    271.
#>  8 rcp85 2003-01-08 CCSM4 r6i1p1   windcave    276.
#>  9 rcp85 2003-01-09 CCSM4 r6i1p1   windcave    271.
#> 10 rcp85 2003-01-10 CCSM4 r6i1p1   windcave    273.
#> # … with 1,816 more rows

Because this is a data.frame, you can use all of the normal data visualization and processing functionality in R, e.g.,

df %>%
  ggplot(aes(date, tasmax)) + 
  geom_point() + 
  geom_line(alpha = .1) + 
  xlab("Date") + 
  ylab("Max. air temp. (K)") + 
  ggtitle("Wind Cave National Park, CCSM4, RCP 8.5")

Dive deeper

This is just a small glimpse at what you can do with the cft package. For more, see Getting started with the Climate Futures Toolbox.

Development instructions

Building documentation

The vignettes in this package are pre-rendered because they take a while to execute. The Makefile contains instructions for rendering the vignettes, as well as the manual and file. To build the documentation, execute the following command from the terminal:


Using Docker instead of a local installation

If you are having trouble installing this package locally, or do not want to install the package locally, we also provide a Docker image that has the package and its dependencies pre-installed, along with RStudio server which can run in a web browser.

To use the Docker image, you’ll need to have Docker installed (see Docker installation instructions here), then run the following command from a terminal, replacing with a password of your choosing.

docker run -e PASSWORD=<yourpassword> -d -p 8787:8787 earthlab/cft

Then, in a web browser, navigate to localhost:8787. Log in with username: rstudio, and the password you provided.