Title: | Finnish Biodiversity Indicators |
---|---|
Description: | Finnish biodiversity indicators is a service providing time series of abundance indices and related metrics for Finland. The input data for the indices are provided by the Finnish Biodiversity Information Facility. |
Authors: | Finnish Museum of Natural History - Luomus [cph], William K. Morris [aut, cre] |
Maintainer: | William K. Morris <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.11.24.9000 |
Built: | 2024-09-27 13:24:48 UTC |
Source: | https://github.com/luomus/fin-biodiv-indicators |
Check indicator inputs
check_input(index, model, taxon)
check_input(index, model, taxon)
index |
Character. Which index? |
model |
Character. Which model? |
taxon |
Character. Which taxon? |
Remove unneeded tables and rows from database cache.
clean_cache(db)
clean_cache(db)
db |
Connection. Database cache. |
Combine count data with survey data
combine_with_surveys(counts, surveys, ...)
combine_with_surveys(counts, surveys, ...)
counts |
Count data. |
surveys |
Survey data. |
... |
Additional arguments. |
This function combines counts
and surveys
data. It performs an
inner join of counts
on surveys
by document_id
. The function assumes
that both counts
and surveys
data include document_id
.
Combine year, month, day of survey into a single date string
format_date(surveys, ...)
format_date(surveys, ...)
surveys |
Survey data. |
... |
Additional arguments. |
This function combines survey year
, month
and day
into a
character string with -
as a separator. The function assumes that survey
data includes year
, month
and day
.
Get indices from a configuration file.
get_indices(file = Sys.getenv("R_CONFIG_FILE"))
get_indices(file = Sys.getenv("R_CONFIG_FILE"))
file |
Configuration file. |
Get serialized indicator outputs
get_output(output, index, model, taxon, region, db)
get_output(output, index, model, taxon, region, db)
output |
Character. Which type of output? |
index |
Character. Update which index? |
model |
Character. Which model to use? |
taxon |
Character. Which taxon? |
region |
Character. Which region? |
db |
Connection. Database from which to get output. |
Pick first survey in each fortnight discarding subsequent surveys
pick_first_survey_in_fortnight(surveys, ...)
pick_first_survey_in_fortnight(surveys, ...)
surveys |
Survey data. |
... |
Additional arguments. |
This function groups surveys by location_id
, year
and
fortnight
then orders them by date. All but the first survey in each group
is removed. If two or more surveys share the same date and location_id
then one is picked at random and the rest are removed. The function assumes
that the surveys
data includes day
, and year
(as integers) and
location_id
, and has been processed by the function
require_seven_fortnights
.
Pick first winter survey in each year discarding subsequent surveys
pick_first_survey_in_winter(surveys, ...)
pick_first_survey_in_winter(surveys, ...)
surveys |
Survey data. |
... |
Additional arguments. |
This function moves surveys occurring in December ahead one year
.
This enables all December surveys to be grouped with subsequent surveys
occurring in the January of the same winter. Surveys are then grouped by
location_id
and year
and then ordered by date. Then all but the first
survey in each group is removed. If two or more surveys share the same date
and location_id
then one is picked at random and the rest are removed.
This function works on the assumption that surveys are in winter from
December to January and that the surveys
data includes day
, month
and
year
(as integers) and location_id
.
Pick first survey in each year discarding subsequent surveys
pick_first_survey_in_year(surveys, ...)
pick_first_survey_in_year(surveys, ...)
surveys |
Survey data. |
... |
Additional arguments. |
This function groups surveys by location_id
and year
then orders
them by date. All but the first survey in each group is removed. If two or
more surveys share the same date and location_id
then one is picked at
random and the rest are removed. The function assumes that the surveys
data includes day
, month
and year
(as integers) and location_id
.
Functions to process indicator input data.
process_funs()
process_funs()
Discard locations where taxa always had zero abundance
remove_all_zero_locations(counts, ...)
remove_all_zero_locations(counts, ...)
counts |
Count data. |
... |
Additional arguments. |
This function groups counts
by location_id
and then removes all
counts
includes location_id
and abundance
.
Remove survey site-years that too many or to large sampling gaps.
require_minimum_gaps(surveys, ...)
require_minimum_gaps(surveys, ...)
surveys |
Survey data. |
... |
Additional arguments. |
This function groups surveys data by location_id
and year
. It
then removes groups where the survey period has too many or too large
sampling gaps. Where too many is defined as a total gap length over the
year
of 21 days and too large is any single sampling gap of more than
7 days. The function expects the surveys
data to have at least
location_id
, year
, ordinal_day_start
and ordinal_day_end
.
Remove survey site-years from a region covering less than a minimum number of weeks.
require_minimum_weeks(surveys, ...)
require_minimum_weeks(surveys, ...)
surveys |
Survey data. |
... |
Additional arguments. |
This function groups surveys data by location_id
and year
. It
then removes groups where the survey period is less than a minimum number
of weeks for a given region
. It expects the surveys
data to have at
least location_id
, year
, region
, ordinal_day_start
and
ordinal_day_end
.
Divide year into approximate 2 week blocks, selecting blocks 10-16 and discarding locations without a survey in each remaining block
require_seven_fortnights(surveys, ...)
require_seven_fortnights(surveys, ...)
surveys |
Survey data. |
... |
Additional arguments. |
This function assigns each survey to an approximate fortnight. A
fortnight is defined as all the days before the 16th day
of each month
and all the days after the 15th day
of each month
. Then all the surveys
falling outside of the date range of the seven fortnights from the second
fortnight of May to the second fortnight of August are removed. Surveys are
then grouped by location_id
and year
and all surveys belonging to groups
that do not have at least one survey occurring in each of the seven
remaining fortnights are discarded. The function assumes that the surveys
data has day
, month
and year
(as integers) and location_id
.
Discard locations with less than two survey years
require_two_years(surveys, ...)
require_two_years(surveys, ...)
surveys |
Survey data. |
... |
Additional arguments. |
This function groups surveys
by location_id
and then removes all
surveys for locations that do not have data in more than one year
. The
function assumes that surveys
has data for location_id
and year
.
Discard counts from years before the start year
set_start_year(counts, taxon, ...)
set_start_year(counts, taxon, ...)
counts |
Count data. |
taxon |
Taxon configuration. |
... |
Additional arguments. |
This function sets a start year for a taxon counts
. If a variable
start_year
has been configured for the given taxon all count data prior
to the start_year
is removed.
Sum the counts over the surveys or taxa in each year
sum_by_event(counts, ...)
sum_by_event(counts, ...)
counts |
Count data. |
... |
Additional arguments. |
This functions groups count data by location_id
and year
. If
multiple taxa counts
are input then data is also grouped by taxa. Counts
are then summed across the survey events at the locations and years.
Sum counts over the sections of surveys
sum_over_sections(counts, ...)
sum_over_sections(counts, ...)
counts |
Count data. |
... |
Additional arguments. |
This functions groups count data by document_id
(the IDs of the
individual surveys). If multiple taxa counts
are input then data is also
grouped by taxa. Counts are then summed across survey sections when count
data has been provided as surveys split into parts.
Update input data from FinBIF.
update_data(type, index, taxon, db, do_update = FALSE)
update_data(type, index, taxon, db, do_update = FALSE)
type |
Character. Which type of input data (e.g., surveys or counts) |
index |
Character. Update the data of which index? |
taxon |
Character. Update the data for which taxon? Ignored if
|
db |
Connection. Database in which to update the data from FinBIF. |
do_update |
Logical. Update data regardless of need. |
Update index output data.
update_index(index, model, region, db)
update_index(index, model, region, db)
index |
Character. Update which index? |
model |
Character. Which model to use? |
region |
Character. Which region? |
db |
Connection. Database in which to update index. |
Update the relative abundance index for a taxon.
update_taxon_index(index, model, taxon, db)
update_taxon_index(index, model, taxon, db)
index |
Character. Update which index? |
model |
Character. Which model to use? |
taxon |
Character. Update the data for which taxa? |
db |
Connection. Database in which to update index. |
Combine count data with survey data filling missing surveys in count data with zero counts.
zero_fill(counts, surveys, ...)
zero_fill(counts, surveys, ...)
counts |
Count data. |
surveys |
Survey data. |
... |
Additional arguments. |
This function combines counts
and surveys
data. It performs a
right outer join of counts
on surveys
by document_id
. Then all
surveys with no corresponding data for abundance are filled with zero. The
function assumes that both counts
and surveys
data include
document_id
and that counts
data includes abundance
.