Skip to contents

Combines occurrence tables that use different column names (e.g. a GBIF download and your own field or genetic samples) into one table with the standard columns species, lon, lat and source, followed by all original columns (as text). Coordinate and species columns are detected automatically; records without valid coordinates are dropped.

Usage

merge_occurrences(
  ...,
  species = NULL,
  data_type = NULL,
  response = NULL,
  encoding = "latin1"
)

Arguments

...

Named data.frames or paths to CSV files (comma-separated, or semicolon-separated with decimal commas), e.g. merge_occurrences(sNMF = "samples.csv", GBIF = cleaned). Names become the source column.

species

Optional single species name written to every record. If NULL, the species column of each table is used when found.

data_type

The kind of data of each source: one value for all, or a vector named by source, e.g. c(GBIF = "presence_only", survey = "presence_absence"). Sources not named are "presence_only".

response

Optional name of the response column of each source (a vector named by source, or one name for all); see Data types.

encoding

Encoding assumed for text that is not valid UTF-8 (common in CSV files exported from Excel or some databases); such text is converted to UTF-8. Try "CP1250" for Central European files if the repaired characters look wrong.

Value

A data.frame with species, lon, lat, source, data_type, response and the other columns of the inputs.

Details

The order of the inputs matters for thin_by_cell(): when two records fall in the same raster cell, the record from the source listed first is kept (use priority there to change this).

Data types. Integrated species distribution models combine data collected in different ways, each with its own observation model: presence-only records (opportunistic observations, herbarium specimens), presence-absence data from structured surveys and counts or abundances (Morera-Pujol et al. 2023; Zulian et al. 2021). data_type records, per source, which kind each record is ("presence_only", the default, "presence_absence", "abundance" or a label of your own), and response the observed value: 1 for presence-only records, 1/0 for presence-absence, the count or abundance otherwise (for a label of your own, the values of its response column as given, or 1 without one). Both columns survive filter_occurrences(), which can apply different settings to each data type, and are used by export_integrated().

The response is read from the column named in response, or found automatically: occurrenceStatus (Darwin Core: PRESENT/ABSENT), present, presence or pa for presence-absence; individualCount, count, counts or abundance for abundance. Presence-only records whose occurrenceStatus is ABSENT (GBIF downloads contain some) get response 0 and are reported.

References

Morera-Pujol, V., Mostert, P.S., Murphy, K.J., Burkitt, T., Coad, B., McMahon, B.J., Nieuwenhuis, M., Morelle, K., Ward, A.I., Ciuti, S. (2023) Bayesian species distribution models integrate presence-only and presence-absence data to predict deer distribution and relative abundance. Ecography 2023, e06451. doi:10.1111/ecog.06451

Zulian, V., Miller, D.A.W., Ferraz, G. (2021) Integrating citizen-science and planned-survey data improves species distribution estimates. Diversity and Distributions 27, 2498-2509. doi:10.1111/ddi.13416

Examples

a <- data.frame(Longitude = c(10.1, 10.2), Latitude = c(46.1, 46.2))
b <- data.frame(decimalLongitude = c(10.1, 11), decimalLatitude = c(46.1, 47),
                species = "Dryas octopetala", gbifID = c("1", "2"))
merge_occurrences(own = a, GBIF = b, species = "Dryas octopetala")
#> Merged records: GBIF = 2, own = 2
#>            species  lon  lat source     data_type response Longitude Latitude
#> 1 Dryas octopetala 10.1 46.1    own presence_only        1      10.1     46.1
#> 2 Dryas octopetala 10.2 46.2    own presence_only        1      10.2     46.2
#> 3 Dryas octopetala 10.1 46.1   GBIF presence_only        1      <NA>     <NA>
#> 4 Dryas octopetala 11.0 47.0   GBIF presence_only        1      <NA>     <NA>
#>   decimalLongitude decimalLatitude gbifID
#> 1             <NA>            <NA>   <NA>
#> 2             <NA>            <NA>   <NA>
#> 3             10.1            46.1      1
#> 4               11              47      2