How mikejohnson51/climater works
Project type and purpose
• This is an R package (library) published to CRAN/GitHub.
• Purpose: provide a “catalog + data‐access toolkit + shortcuts” for fetching spatio-temporal climate, land‐cover, and soils data from remote gridded data services (OPeNDAP, COG, VRT, ERDDAP).
• Secondary purposes: integrate with AOI (area-of-interest) and zonal packages; build documentation site via pkgdown; maintain CI/CD via GitHub Actions.
File structure
Top-level directories/files:
• R/ – core R source modules (catalog, dap, shortcuts, utilities, viz, zarr, netrc).
• man/ – Rd reference pages.
• data–raw/ + data/ + inst/ – packaged example data, built catalog.
• vignettes/ + docs/ – tutorials and pkgdown-built website.
• tests/ – testthat unit tests.
• .gitignore, DESCRIPTION, NAMESPACE, README.Rmd, pkgdown config, GitHub workflows (.github/workflows).
Architectural hints: single holistic package, but internally subdivided into three functional layers:
1. Catalog management (metadata registry)
2. Data access primitives (dap, read_dap_file, zarr, etc.)
3. User-facing shortcuts (getGridMET, getMODIS, getNLCD, etc.)
Key insights from README.md
• Three pillars: federated catalog (monthly auto-rebuild), general data-access API, high-level shortcuts.
• Integration points: AOI package for geometries; zonal for areal summaries; terra for raster handling; netrc for authentication.
• External dependencies: OPeNDAP servers, ERDDAP, COG, VRT, remote HTTP.
Main components and interactions
A. Core climateR Package (inside the R process)
– Catalog Module (R/catalog.R, data/catalog.rda, data-raw)
– Data-Access Module (R/dap.R, R/zarr.R, R/extract-sites.R)
– Shortcuts Module (R/shortcuts.R)
– Utilities (auth via netrc, wgt via meta_tools, visualization via viz)
B. External R Packages
– AOI (defines spatial extents)
– terra (raster handling)
– zonal (future summaries)
– OPeNDAP endpoints (GridMET, MACA, MODIS, etc.)
– COG endpoints (NLCD, soils)
– VRT endpoints (USGS 3DEP)
– ERDDAP servers (CHIRPS, etc.)
D. User/Client
– R script or interactive session calls climateR functions.
E. CI/CD and Documentation
– GitHub Actions (R-CMD-check, test-coverage)
– pkgdown build (docs/ → docs site)
1. User → climateR API (catalog, data-access, shortcuts)
2. climateR → AOI (geometry definitions)
3. climateR data-access → remote services (OPeNDAP, COG, VRT, ERDDAP) over HTTP/OPeNDAP
4. Remote service → climateR (SpatRaster or array)
5. climateR → terra / into R objects → back to user
6. Optional: climateR output → zonal for summaries → back to user
7. CI/CD pipeline triggers: push → GitHub Actions → run tests → build pkgdown site → deploy docs
Architectural patterns and design principles
• Modular layering: separate catalog, low-level API, high-level shortcuts.
• Dependency inversion: user code depends on high-level shortcuts; shortcuts rely on low-level API, which talk to external services.
• Single-responsibility: each R file/module has a narrow focus.
• Federated metadata: catalog is external but packaged; monthly auto-update via data-raw script.
• Stateless client: climateR does not host a server; all remote calls are live, no local server component.