Export Spatial Pipeline Outputs as Web-Ready JSON / GeoJSON
Source:R/export.R
export_pds_spatial.RdReads the pre-computed H3 effort grid and CPUE Parquet files from cloud storage, derives fishing grounds, and uploads web-ready files that can be fetched directly by a Next.js / DeckGL application.
Three versioned files are produced (following the package's `add_version()` convention, i.e. `prefix__YYYYMMDDHHMMSS__extension`): - `pds-h3-effort-rh3_res__*__json`: JSON array for `H3HexagonLayer` - `pds-cpue-rh3_res__*__json`: JSON array for `H3HexagonLayer` - `pds-fishing-grounds__*__geojson`: GeoJSON `FeatureCollection` for `GeoJsonLayer`
Usage
export_pds_spatial(
h3_res = 9L,
min_trips_grounds = 3L,
log_threshold = logger::DEBUG,
package = "coasts"
)Arguments
- h3_res
Integer. H3 resolution of the effort grid to export. Default is `9L`.
- min_trips_grounds
Integer. Minimum unique trips per H3 cell to include in fishing grounds derivation. Default is `3L`.
- log_threshold
Logging threshold. Default is `logger::DEBUG`.
- package
Name of the package whose `inst/conf.yml` to read. Defaults to `"coasts"`.
Details
Files follow the same versioning convention as other pipeline outputs (`add_version()`). The consuming Next.js app uses `cloud_object_name()` or an equivalent GCS listing + timestamp sort to discover the latest version.
Schema for each file: - **Effort JSON** (per H3 cell × year): `[h3_index, year, fishing_hours, unique_trips, n_active_days, avg_fidelity, constancy, avg_hours_per_day, avg_visits_per_day, hours_per_trip]` - **CPUE JSON**: `[h3_index, country, species, cpue, n_trips, lon, lat]` - **Fishing grounds GeoJSON** (same metrics, plus ground-specific): `ground_id, area_km2, n_cells, fishing_hours, unique_trips, n_active_days, avg_fidelity, constancy, avg_hours_per_day, avg_visits_per_day, hours_per_trip, fishing_hours_per_km2, unique_trips_per_km2, hours_per_day_per_km2`