Skip to contents

Processes validated survey data from WorldFish sources, filtering out flagged submissions and generating summary datasets for various dimensions:

  • Monthly summaries with aggregated catch metrics

  • Taxa summaries with species-specific information

  • District summaries with submission and effort metrics

  • Gear summaries with gear-specific performance metrics

  • Grid summaries from vessel tracking data

Usage

summarize_data(
  exclude_dashboard_ids = NULL,
  log_threshold = logger::DEBUG,
  package = "coasts"
)

Arguments

exclude_dashboard_ids

Optional character vector of survey_id values to keep out of the country dashboard summaries (e.g. legacy sources or forms that should not surface there). Rows matching these ids are dropped from monthly_summaries, taxa_summaries, districts_summaries, gear_summaries, length_summaries and gear_taxa_summaries. They are kept in all_monthly_summaries and in <country>_fishery_metrics, which feed the multi-country coasts portal. Defaults to NULL, in which case the list is read from the package config at surveys$summaries$exclude_dashboard_ids (each downstream package manages its own list). If neither is set, all surveys are kept.

log_threshold

The logging level threshold for the logger package (e.g., DEBUG, INFO) See logger::log_levels for available options.

package

Name of the package whose inst/conf.yml to read. Defaults to "coasts". Pass your own package name when calling from a downstream package with a compatible configuration.

Value

NULL (invisible). The function uploads summary files to cloud storage as a side effect.

Details

The function performs the following operations:

  • Retrieves validated WF survey data

  • Filters for approved validation status

  • Stops if a district name and its GAUL code do not match one to one, since the summaries and the GPS tracker method join districts by name

  • Creates multiple summary datasets:

    • Monthly summaries: Average catch, price, CPUE, and RPUE by district and month

    • All monthly summaries: the same recipe over every survey form, ignoring exclude_dashboard_ids; consumed by the multi-country coasts portal

    • Taxa summaries: Catch, catch-weighted mean length and price by species, district, and month

    • District summaries: Submission counts, effort, and catch and revenue per trip by district (with its GAUL level 1 and 2 codes and names)

    • Gear summaries: Performance metrics by gear type

    • Grid summaries: Downloaded from cloud storage

    • Taxa traits: one row per landed taxon with its FishBase traits (from the taxa_enriched table enrich_taxa() writes to the hub bucket)

    • Length summaries: recorded catch per length class, species, gear, district and month. Where a country's API rows carry the mean length of the fish measured (Kenya's KEFS), the classes hold those averages

    • Gear taxa summaries: recorded catch and trips per gear, species, district and month

  • Uploads all summaries to cloud storage as versioned parquet files

The metrics calculated include:

  • Total and mean catch weight

  • Price per kg of catch

  • CPUE (Catch Per Unit Effort) - both hourly and daily

  • RPUE (Revenue Per Unit Effort) - both hourly and daily

  • Number of submissions and fishers

  • Trip duration

See also

Examples

if (FALSE) { # \dontrun{
# Summarize WF data with default debug logging
summarize_data()

# Summarize with info-level logging only
summarize_data(logger::INFO)

# Keep specific forms out of the dashboard explicitly (overrides config list)
summarize_data(exclude_dashboard_ids = c(
  conf$ingestion$wcs$koboform$asset_id,
  conf$ingestion$wcs$koboform_kf$asset_id_kf,
  "legacy"
))
} # }