Package 'esas'

Title: Read and Process Data from European Seabirds At Sea
Description: Read and process data from European Seabirds At Sea ('ESAS').
Authors: Pieter Huybrechts [aut, cre] (ORCID: <https://orcid.org/0000-0002-6658-6062>, affiliation: Research Institute for Nature and Forest (INBO)), Nicolas Vanermen [aut] (ORCID: <https://orcid.org/0000-0003-0156-357X>, affiliation: Research Institute for Nature and Forest (INBO)), Robin Daelemans [ctb] (ORCID: <https://orcid.org/0000-0003-0887-3140>, affiliation: Research Institute for Nature and Forest (INBO)), Peter Desmet [ctb] (ORCID: <https://orcid.org/0000-0002-8442-8025>, affiliation: Research Institute for Nature and Forest (INBO)), Research Institute for Nature and Forest (INBO) [cph] (ROR: <https://ror.org/00j54wy13>), European Union [fnd] (https://doi.org/10.3030/101112823)
Maintainer: Pieter Huybrechts <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2026-10-09 10:26:48 UTC
Source: https://github.com/inbo/esas

Help Index


Execute distance analysis on ship-based survey results

Description

This function calculates detection probabilities for specified species from ship-based survey data using distance sampling methods. It filters the input data for relevant observations, fits half-normal and hazard-rate models, and selects the best model based on AIC values. The output is a data frame containing species names, the selected model function, and the average detection probability.

Usage

Calculate_Detection_P_Ship_Based_Surveys(
  esas_table_2_analyse,
  species_2_analyse
)

Arguments

esas_table_2_analyse

A data frame containing survey data with columns for distance bins, platform class, transect type, observation distance, species code, behavior, and count. As returned by Create_ESAS_Table().

species_2_analyse

A vector of species codes as encoded in the species column of the Observations table in the ESAS Data Model. See the Species page of the Data Model.

Value

A data.frame with the following columns:

  • Species: The species code.

  • Function: The selected detection function ("HR" for hazard-rate or "HN" for half-normal).

  • Detection_P_AVG: The average detection probability for the species.

See Also

Other analysis functions: Create_ESAS_Table(), Create_Seabird_Density_Cross_Table()

Examples

# Read 4 ESAS tables:
path_to_read <- system.file("extdata", "ESAS_0827343782", package = "esas")
esas_tables_list <- Read_ESAS_Tables(
  path = path_to_read,
  file_encoding = "UTF-8"
)

# Create an ESAS master-table:
esas_table <- Create_ESAS_Table(esas_tables_list = esas_tables_list)


# Execute distance analysis on selection of species:
Calculate_Detection_P_Ship_Based_Surveys(
  esas_table_2_analyse = esas_table,
  species_2_analyse = c(720, 6020)
)

Combine the tables from the ESAS Data Model into a single data.frame

Description

The Analysis functions in this R package expect a single data.frame as input. This function combines the tables from the ESAS Data Model into a single data.frame. It performs left joins to ensure that all records from the CAMPAIGNS, SAMPLES, POSITIONS, and OBSERVATIONS tables are included. It also renames the Notes columns from the CAMPAIGNS and SAMPLES tables to avoid naming conflicts.

Usage

Create_ESAS_Table(esas_tables_list)

Arguments

esas_tables_list

A list containing the ESAS tables as data.frames. The list should include the following named elements: CAMPAIGNS, SAMPLES, POSITIONS, and OBSERVATIONS.

Value

A single data.frame that combines the information from the CAMPAIGNS, SAMPLES, POSITIONS, and OBSERVATIONS tables.

See Also

Other analysis functions: Calculate_Detection_P_Ship_Based_Surveys(), Create_Seabird_Density_Cross_Table()

Examples

# Read 4 ESAS tables:
path_to_read <- system.file("extdata", "ESAS_0827343782", package = "esas")
esas_tables_list <- Read_ESAS_Tables(
  path = path_to_read,
  file_encoding = "UTF-8"
)

# Create an ESAS master-table:
esas_table <- Create_ESAS_Table(esas_tables_list = esas_tables_list)
esas_table

Create a cross-table with distance-corrected bird densities

Description

This function processes seabird observation data to create a cross-table of distance-corrected bird densities for selected species. It filters the data based on specific criteria, applies detection probability corrections, and calculates densities per unit area. The resulting table includes relevant metadata such as date, time, area, and location.

Usage

Create_Seabird_Density_Cross_Table(
  esas_table,
  probabilities,
  species_selection
)

Arguments

esas_table

A data frame containing seabird observation data as resulting from the Create_ESAS_Table() function.

probabilities

A data frame containing detection probabilities for different species as returned by Calculate_Detection_P_Ship_Based_Surveys()

species_selection

A vector of species codes to include in the analysis as encoded in the species column of the Observations table in the ESAS Data Model. See the Species page of the Data Model.

Details

Requirements:

  • DistanceBins must be 0|50|100|200|300

  • PlatformClass must be 30 (ship-based surveys)

  • Area must be greater than 0

  • ObservationDistance must be F for flying birds and A, B, C, or D for swimming/diving birds

  • Transect must be True

  • Behaviour must not be 99

  • Species codes must be provided in species_selection and must exist in the esas_table

Value

A data frame containing distance-corrected bird densities for the selected species.

See Also

Other analysis functions: Calculate_Detection_P_Ship_Based_Surveys(), Create_ESAS_Table()

Examples

path_to_read <- system.file("extdata", "ESAS_0827343782", package = "esas")
esas_table <- Create_ESAS_Table(Read_ESAS_Tables(path = path_to_read))
Create_Seabird_Density_Cross_Table(
  esas_table = esas_table,
  probabilities =
    Calculate_Detection_P_Ship_Based_Surveys(esas_table,
                                             species_2_analyse = c(720,6000)),
  species_selection = c(720, 6020)
)

Write a tab delimited csv file as expected by the ESAS upload module.

Description

This function exports a data frame to a tab-delimited file without row names, column names, or quotes, using the specified file encoding.

Usage

Export_ESAS_Upload_Matrix(table, path, filename)

Arguments

table

A data frame or matrix to be exported as returned by Transform_ESAS_Tables_4_Upload()

path

Directory path where the file will be saved.

filename

Character string specifying the name of the output file without the extension.

Value

(invisible) The path to the exported file.

See Also

Other upload functions: Transform_ESAS_Tables_4_Upload()

Examples

#Read 4 ESAS tables:
data_path <- system.file("extdata", "ESAS_INBO_202401", package = "esas")
esas_tables_list <- Read_ESAS_Tables(path = data_path,
                                     file_encoding = "UTF-8")

#Convert tables to upload format:
esas_4_upload <- Transform_ESAS_Tables_4_Upload(campaigns_tbl = esas_tables_list$CAMPAIGNS,
                                                samples_tbl = esas_tables_list$SAMPLES,
                                                positions_tbl = esas_tables_list$POSITIONS,
                                                observations_tbl = esas_tables_list$OBSERVATIONS,
                                                data_provider = "202",
                                                country = "BE")

## Not run: 
#Export upload table:
Export_ESAS_Upload_Matrix(table = esas_4_upload,
                          path = tempdir(),
                          filename = "esas_4_upload")

## End(Not run)

Read csv files and combine them into a single data.frame

Description

Read 4 csv files (CAMPAIGNS, SAMPLES, POSITIONS, OBSERVATIONS) and combine them into a list of data.frames.

Usage

Read_ESAS_Tables(path, file_encoding = "UTF-8")

Arguments

path

(Character.) Path to the directory containing 4 csv files as returned by the ESAS Data inventory. It should contain the files: "Campaigns.csv", "Samples.csv", "Positions.csv" and "Observations.csv".

file_encoding

(Character.) File encoding. Default is "UTF-8".

Value

A list of 4 data.frames: CAMPAIGNS, SAMPLES, POSITIONS, OBSERVATIONS.

Examples

data_path <- system.file("extdata", "ESAS_0827343782", package = "esas")
Read_ESAS_Tables(data_path)

Combine the 5 tables from the ESAS Data Model to a single data.frame as preparation for uploading

Description

The resulting data.frame has 18 columns, where the first column is "RecordType" which indicates the type of record (FI, EC, ES, EP, EO). The remaining columns are filled with the respective data from the input tables.

Usage

Transform_ESAS_Tables_4_Upload(
  campaigns_tbl,
  samples_tbl,
  positions_tbl,
  observations_tbl,
  data_provider,
  country
)

Arguments

campaigns_tbl

(data.frame) of campaigns table as returned by Read_ESAS_Tables()⁠$CAMPAIGNS⁠

samples_tbl

(data.frame) of samples table as returned by Read_ESAS_Tables()⁠$SAMPLES⁠

positions_tbl

(data.frame) of positions table as returned by Read_ESAS_Tables()⁠$POSITIONS⁠

observations_tbl

(data.frame) of observations table as returned by Read_ESAS_Tables()⁠$OBSERVATIONS⁠

data_provider

(integer) code of the data provider as described by the ESAS Data Model file information table.

country

(character) ISO_3166 country code of the data provider. For example: "BE".

Value

(data.frame) with 18 columns and a number of rows equal to the sum of rows of the input tables plus one (for the file information row).

See Also

Other upload functions: Export_ESAS_Upload_Matrix()

Examples

## Not run: 
ESAS_TABLES_LIST <-
  Read_ESAS_Tables(
    path = "local_folder_with_downloaded_files",
    file_encoding = "UTF-8"
  )

Transform_ESAS_Tables_4_Upload(
  campaigns_tbl = ESAS_TABLES_LIST$CAMPAIGNS,
  samples_tbl = ESAS_TABLES_LIST$SAMPLES,
  positions_tbl = ESAS_TABLES_LIST$POSITIONS,
  observations_tbl = ESAS_TABLES_LIST$OBSERVATIONS,
  data_provider = "202",
  country = "BE"
)

## End(Not run)