1 GEE: Harmonic Regression

In this project we want to explore to what degree environmental predictability can explain species declines among sub-Saharan migrant songbirds. We define environmental predictability as the degree to which a simple harmonic regression model can fit the seasonal changes of environmental variables in the wintering areas of these sub-Saharan migrants.

To be able to run this harmonic time series analysis on a fine-scale across the full extent of wintering ranges of these birds, we use the Google Earth Engine (GEE).

1.1 Apply harmonic regression to GEE datasets

The function R/rgee_harmonic_regression.R contains the code necessary to run the harmonic regression on GEE using the rgee package. Most of the harmonic regression analysis code is based on those provided by the Google Earth Engine team in the Time series analysis lab, with a few tweaks for our use-case as listed in the R/rgee_harmonic_regression.R document. We export the harmonic regression results at a 10km resolution and limit the spatial domain to the following area, denoted by the red square.

aoi <- read_sf("data/raw/studyarea.geojson")
world <- ne_countries(returnclass = "sf")

ggplot() +
  geom_sf(data = world) +
  geom_sf(data = aoi, fill = NA, color = "red")

Obviously that area spans much more than just Africa, but for our interpretation of results (and possible future expansion of the analysis to include breeding areas), this is more beneficial.

We can now run the harmonic regression on GEE and generate GeoTIFFs for each of the analyses. As we are particularly interested in NDVI we use the temporal range of the NASA/GIMMS/3GV0 dataset (in GEE) to determine the time frame over which to run the analysis.

source("R/rgee_harmonic_regression.R")

res <- 10000

ndvi1 <- rgee_harmonic_regression(dataset = "NASA/GIMMS/3GV0", dependent = "ndvi", harmonics = 1, 
                                  aoi = aoi, resolution = res, dsn = "data/raw/gee/ndvi_1.tif", mask = -1)
ndvi2 <- rgee_harmonic_regression(dataset = "NASA/GIMMS/3GV0", dependent = "ndvi", harmonics = 2,
                                  aoi = aoi, resolution = res, dsn = "data/raw/gee/ndvi_2.tif", mask = -1)
aet1 <- rgee_harmonic_regression(dataset = "IDAHO_EPSCOR/TERRACLIMATE", dependent = "aet", harmonics = 1,
                                 aoi = aoi, resolution = res, dsn = "data/raw/gee/aet_1.tif",
                                 refdataset = "NASA/GIMMS/3GV0")
aet2 <- rgee_harmonic_regression(dataset = "IDAHO_EPSCOR/TERRACLIMATE", dependent = "aet", harmonics = 2,
                                 aoi = aoi, resolution = res, dsn = "data/raw/gee/aet_2.tif",
                                 refdataset = "NASA/GIMMS/3GV0")
pet1 <- rgee_harmonic_regression(dataset = "IDAHO_EPSCOR/TERRACLIMATE", dependent = "pet", harmonics = 1,
                                 aoi = aoi, resolution = res, dsn = "data/raw/gee/pet_1.tif",
                                 refdataset = "NASA/GIMMS/3GV0")
pet2 <- rgee_harmonic_regression(dataset = "IDAHO_EPSCOR/TERRACLIMATE", dependent = "pet", harmonics = 2,
                                 aoi = aoi, resolution = res, dsn = "data/raw/gee/pet_2.tif",
                                 refdataset = "NASA/GIMMS/3GV0")
pr1 <- rgee_harmonic_regression(dataset = "IDAHO_EPSCOR/TERRACLIMATE", dependent = "pr", harmonics = 1,
                                aoi = aoi, resolution = res, dsn = "data/raw/gee/pr_1.tif",
                                refdataset = "NASA/GIMMS/3GV0")
pr2 <- rgee_harmonic_regression(dataset = "IDAHO_EPSCOR/TERRACLIMATE", dependent = "pr", harmonics = 2,
                                aoi = aoi, resolution = res, dsn = "data/raw/gee/pr_2.tif",
                                refdataset = "NASA/GIMMS/3GV0")
tmmn1 <- rgee_harmonic_regression(dataset = "IDAHO_EPSCOR/TERRACLIMATE", dependent = "tmmn", harmonics = 1,
                                  aoi = aoi, resolution = res, dsn = "data/raw/gee/tmmn_1.tif",
                                  refdataset = "NASA/GIMMS/3GV0")
tmmn2 <- rgee_harmonic_regression(dataset = "IDAHO_EPSCOR/TERRACLIMATE", dependent = "tmmn", harmonics = 2,
                                  aoi = aoi, resolution = res, dsn = "data/raw/gee/tmmn_2.tif",
                                  refdataset = "NASA/GIMMS/3GV0")
tmmx1 <- rgee_harmonic_regression(dataset = "IDAHO_EPSCOR/TERRACLIMATE", dependent = "tmmx", harmonics = 1,
                                  aoi = aoi, resolution = res, dsn = "data/raw/gee/tmmx_1.tif",
                                  refdataset = "NASA/GIMMS/3GV0")
tmmx2 <- rgee_harmonic_regression(dataset = "IDAHO_EPSCOR/TERRACLIMATE", dependent = "tmmx", harmonics = 2,
                                  aoi = aoi, resolution = res, dsn = "data/raw/gee/tmmx_2.tif",
                                  refdataset = "NASA/GIMMS/3GV0")
def1 <- rgee_harmonic_regression(dataset = "IDAHO_EPSCOR/TERRACLIMATE", dependent = "def", harmonics = 1,
                                 aoi = aoi, resolution = res, dsn = "data/raw/gee/def_1.tif",
                                 refdataset = "NASA/GIMMS/3GV0")
def2 <- rgee_harmonic_regression(dataset = "IDAHO_EPSCOR/TERRACLIMATE", dependent = "def", harmonics = 2,
                                 aoi = aoi, resolution = res, dsn = "data/raw/gee/def_2.tif",
                                 refdataset = "NASA/GIMMS/3GV0")