How kvos/coastsat works
Project type and purpose
• Project type: Open‑source Python toolkit / library (no web UI) for automated shoreline detection, time‑series analysis and tidal correction.
• Key goal: Download satellite imagery (Landsat, Sentinel‑2) → preprocess → classify pixels → extract shorelines → intersect with transects → apply tidal correction & slope estimation → output results (GeoJSON, pickles, plots).
File structure
• Top‑level modules:
– coastsat/ : core Python package modules (SDS_download, SDS_preprocess, SDS_classify, SDS_shoreline, SDS_transects, SDS_tools)
– classification/ : training data, Jupyter notebook, ML models (.pkl)
– examples/ & example.py/ipynb: demonstration scripts and sample data
– doc/ : documentation & setup guides
• Config & CI: .github/workflows/test‑coastsat.yml for tests, dependencies in README.
• Outputs: .geojson, .pkl, .mp4, figures saved to user‐specified “filepath/sitename” directory.
README insights
• Describes six functional blocks: retrieval, detection, transects intersection, tidal correction & slope, postprocessing, validation.
• Lists external dependencies: Google Earth Engine API, FES2022 tide model, GDAL, geopandas, scikit‑image, PyFES, etc.
1. User Interface (CLI or notebooks/scripts)
2. Image Retrieval Module (SDS_download → calls Google Earth Engine API)
3. Preprocessing Module (SDS_preprocess → reprojection, cloud masking, pansharpening)
4. Classification Module (ML models loaded from classification/models/*.pkl → pixel labelling into sand/water/whitewater/other)
5. Shoreline Extraction Module (SDS_shoreline → segmentation + thresholding → polyline generation)
7. Tidal Correction & Slope Estimation (SDS_transects + external FES2022 service or CSV tide inputs + CoastSat.slope library)
8. Post‑Processing & Analysis (despiking, seasonal/monthly averages, trend estimation)
9. Output & Visualization (GeoJSON exports, .pkl pickles, plots, timelapse MP4 via SDS_tools)
10. Data Storage (local filesystem: imagery, intermediate files, outputs)
11. External Services:
– Google Earth Engine
– Global tide model (FES2022)
• Image Retrieval → writes → Raw imagery files → Preprocessing Module
• Preprocessing → writes → Preprocessed imagery → Classification Module
• Classification → writes → Classified raster → Shoreline Extraction Module
• Shoreline Extraction → writes → Shorelines (GeoJSON + Python objects) → Transect Module
• Transect Module ↔ Tidal Correction & Slope Estimation (requires tide time‑series + slope)
• Tidal Correction & Slope → writes → Corrected shoreline time‑series → Post‑Processing & Analysis
• Post‑Processing → writes → Final outputs (GeoJSON, .pkl, figures)
• Transect Module & Post‑Processing → may call → SDS_tools for animations, plots
c. Architectural patterns & design principles:
• Modular pipeline: clear separation of concerns between retrieval, preprocessing, analysis, output.
• Plug‑in ML classifiers: .pkl files under classification/models can be swapped or retrained.
• Extensibility points: add new cloud‑mask algorithms, new classifiers, alternate tidal models.
• Data‑centric: each stage reads/writes files on disk to maximize reproducibility and checkpointing.
• Python 3.11, Earth Engine API, GDAL, geopandas, shapely, scikit‑image, numpy, matplotlib
• PyFES for tide predictions, imageio‑ffmpeg for animations
• Jupyter Notebook / Spyder for user interaction
• GitHub Actions for CI testing