# RiverBankErosionAccretionV2

Advanced QGIS plugin for automated riverbank erosion and accretion analysis.
Supports two workflows:

1. **Satellite Fetch** — Search, download, and process Landsat/Sentinel-2
   imagery via STAC API; extract water using multi-index ensemble
   (NDWI, MNDWI, AWEI) with Otsu auto-thresholding; compute changes.
2. **Load Polygons** — Use pre-digitized waterbody layers (existing
   workflow).

## Key Features

- STAC API-based satellite data acquisition (Landsat 5/7/8/9, Sentinel-2)
- Multi-index water extraction (NDWI, MNDWI, AWEI) with ensemble voting
- Otsu automatic thresholding for robust water classification
- Grid-based erosion/accretion area quantification
- Transect-based bank retreat rate-of-change (EPR)
- Optional validation against JRC Global Surface Water
- Exports: Shapefiles, CSVs, validation reports

## Requirements

- QGIS 3.28 or higher
- Python 3.8+
- Required: `geopandas`, `numpy`, `shapely`, `pandas`
- Optional (Satellite Fetch): `pystac-client`, `rasterio`

## How to Use

1. Open the plugin from the QGIS toolbar.
2. Choose input mode: **Satellite Fetch** tab or **Load Polygons** tab.
3. For Satellite Fetch: set AOI, date range, satellite type, search scenes,
   then run.
4. For Load Polygons: select two waterbody polygon layers.
5. Set output folder, projected CRS, cell size, stretch distance.
6. Click **Start Analysis**.

## Output Files

| File | Description |
|---|---|
| `Waterbody_Y1/2.shp` | Extracted/loaded waterbody polygons |
| `Fishnet_Analysis.shp` | Common analysis grid |
| `PerGrid_ErosionAccretion.shp` | Per-cell change statistics |
| `Stretch_Summary.shp` | Aggregated stretch results |
| `TopN_Erosion/Accretion_Stretches.*` | Top-N hotspot identification |
| `Transects.shp` / `Transect_Rates.*` | Transect-based rates |
| `validation/validation_report.txt` | Accuracy metrics |

## Credits

Developed by **Dr. Srija Roy**
