output: github_document editor_options: chunk_output_type: console —
The goal of cft is to provide easy climate data access (MACA v2) to support climate scenario planning. This package allows you to:
Install the development version of cft from GitHub with:
# install.packages("remotes") remotes::install_github("earthlab/cft")
To get daily maximum air temperature data for an area of interest, you can use the
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
This gives you a data frame with paths to local climate data files:
d #> # 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... df #> # 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.,
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.
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 README.md file. To build the documentation, execute the following command from the terminal:
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
Then, in a web browser, navigate to localhost:8787. Log in with username:
rstudio, and the password you provided.