if (interactive()) {
# Initialize TerraClimate data download for specific climate variables between two dates
ini_terraclimate('2018-09-01', '2019-06-30', c('ppt', 'tmin', 'tmax'))
# Coordinates for the location(s) of interest
x <- c(-6.716, 35.917, 76.884)
y <- c(33.616, 33.833, 23.111)
# Extract TerraClimate data for the specified coordinates (online mode)
a <- get_terraclimate(y, x, '2018-09-01', '2019-06-30', c('ppt', 'tmin', 'tmax'))
# View the extracted climate data and bioclimatic variables
View(a$climate[[1]])
View(a$biovars[[1]])
# Extract TerraClimate data for the specified coordinates (offline mode)
b <- get_terraclimate(y, x, '2018-09-01', '2019-06-30', c('ppt', 'tmin', 'tmax'), offline = TRUE)
# View the offline-extracted data
View(b$climate[[1]])
View(b$biovars[[1]])
}
Run the code above in your browser using DataLab