knitr::opts_chunk$set(echo = TRUE)
library(glint)

Introduction

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.

Daily Weather Data Cleaning, Thin Plate Splining and Interpolation

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.

Downloading 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:

Downloading the Digital Elevation Model

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:

Interpolating the GSOD Data

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.

Example Creating a Set of Global GeoTIFF Files from 1983 to 2015

Step 1: Download the GSOD data

future::plan("multisession")
years <- as.list(seq(from = 1983, to = 2015, by = 1))
lapply(X = years, FUN = make_GSOD_set, dsn = "/mnt/GSOD")

Step 2: Download the Digital Elevation Model and Aggregate to 0.5 Degree

DEM <- make_DEM(dsn = "/mnt/DEM")

Step 3: Interpolate the GSOD Data from On-disk Files

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"))

Appendices

Reproducibility

sessioninfo::session_info()


adamhsparks/GRID documentation built on Jan. 27, 2023, 5:48 a.m.