knitr::opts_chunk$set(echo = TRUE) library(glint)
Global Surface Summary of the Day - GSOD data, (link) is free, ground-based (or buoy) weather station data with global coverage. When properly cleaned and interpolated this data can provide a better alternative to NASA POWER data for agroclimatology work. This document describes how to reproduce these data using freely available data, software and methodologies.
The glint package makes this process as simple as possible. Described below are the steps that the package uses internally to create gridded weather data from the GSOD data.
glint offers customised functionality to download GSOD data, get_GSOD()
using functionality from the GSODR package.
glint will provide only the data necessary for interpolation, excluding the other data that GSOD provides while omitting any station that has more than a maximum five missing days to help ensure data quality.
The four variables that glint can interpolate are:
TEMP - Mean daily temperature,
MAX - Daily maximum temperature,
MIN - Daily minimum temperature,
RH - Mean daily relative humidity.
glint offers customised functionality, make_DEM()
to download a digital elevation model based on the Shuttle Radar Topography Mission (SRTM) from WorldClim and aggregated it to:
1 degree (matching historical NASA - POWER data, which could provide rainfall),
0.5 degree (matching NASA - POWER data, which can provide rainfall),
0.25 degree (matching historical CHIRPS data, which can provide rainfall)
glint offers a simple function, interpolate_GSOD()
, to automate error checking, interpolation and saving GeoTIFF files of the resulting data.
When using the interpolate_GSOD()
function, GSOD data are first checked for consistency using boxplot.stats()
to identify and remove daily outliers for any variable requested.
Once the GSOD data are cleaned, thin plate splining, the Tps()
function, from fields is used to create an object that can then be used to create an interpolated surface of temperatures using the SRTM DEM with theinterpolate()
function from terra.
The data are then returned in a list of raster stacks by weather variable in the R session or saved to disk in GeoTIFF file format in an INT2S format with LZW compression for saving disk space.
This is an extremely processor and time-intensive process for the entire global data set. It is suggested to use a computer dedicated just to this task, while it will run on a fairly modest desktop, the computer may become unresponsive while performing this operation.
future::plan("multisession") years <- as.list(seq(from = 1983, to = 2015, by = 1)) lapply(X = years, FUN = make_GSOD_set, dsn = "/mnt/GSOD")
DEM <- make_DEM(dsn = "/mnt/DEM")
file_list <- list.files("/mnt/GSOD", full.names = TRUE)
Since future::plan()
was already set to multisession
previously, that will apply here and the interpolation will automatically be done in parallel.
GRID <- lapply(X = file_list, FUN = interpolate_GSOD, dem = DEM, dsn = "/mnt/Cache/GTiff", vars = c("MAX", "MIN"))
sessioninfo::session_info()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.