
Export Validated API-Ready Trip Data
export_api_validated.RdProcesses WorldFish preprocessed survey data into a simplified API-friendly format and exports it to cloud storage for external consumption. This function exports the validated version of trip data.
Usage
export_api_validated(log_threshold = logger::DEBUG)Arguments
- log_threshold
The logging level threshold for the logger package (e.g., DEBUG, INFO). See
logger::log_levelsfor available options. Default is logger::DEBUG.
Details
The function performs the following operations:
Downloads validated WF survey data from cloud storage
Generates unique trip IDs using xxhash64 algorithm
Transforms nested survey structure to flat API format
Joins with standardized lookup tables (districts, gear types, vessel types)
Exports to the validated cloud storage path (before validation)
Data Pipeline Context: This function exports raw preprocessed data and is part of a two-stage API export pipeline:
raw()- Exports raw/preprocessed dataexport_api_validated()- Exports validated data (this function)
Output Schema: The exported dataset includes the following fields:
trip_id: Unique identifier (TRIP_xxxxxxxxxxxx format)landing_date: Date of landinggaul_2_name: Standardized district name (GAUL level 2)n_fishers: Total number of fishers (men + women + children)trip_duration_hrs: Duration in hoursgear: Standardized gear typevessel_type: Standardized vessel typecatch_habitat: Habitat where catch occurredcatch_outcome: Outcome of catch (landed, sold, etc.)n_catch: Number of individual catch itemscatch_taxon: Species or taxonomic grouplength_cm: Length measurement in centimeterscatch_kg: Weight in kilogramscatch_price: Price in local currency
Cloud Storage Location:
Files are uploaded to the path specified in conf$api$trips$validated$cloud_path
(e.g., kenya/validated/) with versioned filenames following the pattern:
{file_prefix}__{timestamp}_{git_sha}__.parquet
Examples
if (FALSE) { # \dontrun{
# Export raw API trip data with default debug logging
export_api_validated()
# Export with info-level logging only
export_api_validated(logger::INFO)
} # }