
Export Raw API-Ready Trip Data
export_api_raw.RdProcesses WorldFish preprocessed survey data into a simplified API-friendly format and exports it to cloud storage for external consumption. This function exports the raw/preprocessed version of trip data without validation filters. For validated API exports, see the companion function that will process validated surveys.
Usage
export_api_raw(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 preprocessed (not 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 raw cloud storage path (before validation)
Data Pipeline Context: This function exports raw preprocessed data and is part of a two-stage API export pipeline:
export_api_raw()- Exports raw/preprocessed data (this function)(Future)
export_api_validated()- Will export quality-controlled validated data
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$raw$cloud_path
(e.g., kenya/raw/) 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_raw()
# Export with info-level logging only
export_api_raw(logger::INFO)
} # }