This documents outlines how a multi-taxon indicator (Farmland Butterfly Abundance) can be calculated in R.
The following packages are required. All packages are available on CRAN apart from
{fbi}
which can be installed from GitHub.
These five fields are required for the survey data.
These filters restrict the survey data to the “Butterflies in Finnish agricultural landscapes” dataset with the selected data fields have no missing data.
The survey data can now downloaded from FinBIF.
surveys <- finbif_occurrence(
filter = filter,
select = select,
aggregate = "events",
aggregate_counts = FALSE,
n = "all",
quiet = TRUE
)
Two processing functions are applied to the survey data to first limit the surveys to sites where at least seven fortnights have been surveyed and limit each site’s surveys to the first survey in each fortnight.
Count data requires three fields to be selected: the survey
identifier (document_id
) the survey site section
(section
) and the measure of abundance
(abundance_interpreted
).
The count data requires the same filters as the survey data (though
the filter has_value
needs to be redefined).
A set of taxa contributing to the total abundance is selected.
The count data for these taxa can now be downloaded from FinBIF.
counts <- lapply(
taxa,
finbif_occurrence,
filter = filter,
select = select,
n = "all",
quiet = TRUE
)
Three processing functions are applied to the count data to: sum the counts over the survey site sections; combine the count and survey data together; amd sum over the counts for each site-year combination.
counts <- lapply(counts, sum_over_sections)
counts <- lapply(counts, combine_with_surveys, surveys)
counts <- lapply(counts, sum_by_event)
The count data can then be summed across the taxa.
An index of total abundance for each year is created by fitting a TRIM model to the combined data and setting the base year to the year 2000.
ggplot(index) +
aes(
x = parse_date_time(time, "Y"), y = imputed,
ymin = imputed - se_imp, ymax = imputed + se_imp
) +
geom_ribbon(alpha = .2) +
geom_line() +
ylab(NULL) +
xlab(NULL) +
theme_minimal()