Climate layers describe a period (e.g. 1981-2010 for CHELSA V2.1,
1970-2000 for WorldClim 2). Records collected long before or after it
may come from places where the climate was different then, or where the
species no longer occurs. The function labels every record and prints
how many fall inside the period, so that you can decide whether to
restrict the records, widen the period with tolerance, or choose
another climatology.
Usage
match_climate_period(
points,
period = c(1981, 2010),
year = NULL,
tolerance = 0,
verbose = TRUE
)Value
The records with added columns period_match ("within",
"before", "after" or "unknown") and years_outside (0 within;
negative before, positive after). attr(, "summary") holds the
counts, shares and median year of each class.
Examples
occ <- data.frame(lon = 1:6, lat = 50,
year = c(1950, 1985, 1999, 2012, 2021, NA))
m <- match_climate_period(occ, c(1981, 2010))
#> Climate period 1981-2010: 2 within, 1 before, 2 after, 1 unknown; median year of the records: 1999
m[m$period_match == "within", ]
#> lon lat year period_match years_outside
#> 2 2 50 1985 within 0
#> 3 3 50 1999 within 0
