Metadata-Version: 2.4
Name: autofloods
Version: 0.1.0a5
Summary: Automated flood mapping at scale from Sentinel-1 SAR imagery
Author-email: Pratyush Tripathy <tripathyshared@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/PratyushTripathy/AutoFloods
Project-URL: Repository, https://github.com/PratyushTripathy/AutoFloods
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: <3.11,>=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: geopandas==0.13.2
Requires-Dist: fiona==1.9.6
Requires-Dist: rioxarray==0.14.1
Requires-Dist: xarray==2023.6.0
Requires-Dist: pandas==1.5.0
Requires-Dist: rasterio==1.3.3
Requires-Dist: shapely==2.0.1
Requires-Dist: numpy==1.23.2
Requires-Dist: matplotlib==3.6.0
Requires-Dist: xarray-spatial==0.3.7
Requires-Dist: pystac==1.7.2
Requires-Dist: pystac-client==0.6.1
Requires-Dist: scikit-image==0.19.3
Requires-Dist: scikit-learn==1.1.3
Requires-Dist: planetary-computer==1.0.0
Requires-Dist: dask[array]==2023.6.0
Requires-Dist: requests==2.31.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Provides-Extra: docs
Requires-Dist: quartodoc; extra == "docs"
Requires-Dist: griffe<2; extra == "docs"
Dynamic: license-file

![AutoFloods](https://raw.githubusercontent.com/PratyushTripathy/AutoFloods/main/autofloods_logo.png)

AutoFloods is a Python package for automated flood mapping at scale from Sentinel-1 SAR imagery, with pluggable data sources (Microsoft Planetary Computer, NASA OPERA) and detection methods (Z-score, Otsu).

## Quickstart

OPERASource requires a free NASA Earthdata Login; MPCSource works with no credentials at all (a free subscription key just raises rate limits) — see [Authentication](https://autofloods.readthedocs.io/en/latest/getting-started.html#authentication).

<!-- TODO: drop --pre once a stable (non-alpha/beta) 0.1.0 release exists -->
Pre-release: `pip install --pre autofloods`

Basic usage:

```python
from autofloods import flood_mapper
from autofloods.sources import OPERASource

fm = flood_mapper(
    # AOI grid; needs id_col, dry_date_col, zone columns
    grid_shapefile='resources/india_utm_fishnet_buffer.gpkg',

    # which AOI IDs from the grid to process
    grid_id_list=[321],

    # dry-season years to build the baseline from
    dry_years=[2024, 2024],

    # where the terrain-slope mask is cached
    slope_dir='resources/slope/',

    # wet-season date range to classify
    wet_duration=['2024/07', '2024/10'],

    # or MPCSource() (the default)
    source=OPERASource(),

    # root dir for all outputs and caches
    output_dir='output/my_run',
)

# read each AOI's dry season into self.dry_months
fm.get_dry_dates()

# turn dry_months into per-year search date ranges
fm.generate_dry_date_ranges()

# STAC-search the source for dry-season scenes
fm.get_s1_items(dry_wet='dry')

# download + read those scenes
fm.read_scenes(dry_wet='dry', overview_level=None, max_workers=6)

# fit the dry-season Z-score baseline per AOI
fm.generate_mean_std_by_aoi()

# compute/cache the terrain-slope mask
fm.prepare_slope(dem_overview=0, buffer=500)

# search, read, reproject wet-season scenes
fm.prepare_wet_scenes(overview_level=None, max_workers=6)

# classify each scene against the baseline
fm.map_floods(vv_thd=-2.5, vh_thd=-2.5, rel_slope_thd=20,
              export_raster=False, export_vector=False, export_maps=False)

# collapse per-scene results into one band per date
fm.merge_floods_by_date(export_raster=True)

# per-pixel count of scenes with data gaps
fm.generate_number_of_scenes(export_raster=True)

# aggregate per-date results into per-month flood-day counts
fm.monthly_sum()
```

See the documentation for full usage, API reference, and citation details: https://autofloods.readthedocs.io/en/latest/
