Metadata-Version: 2.4
Name: wildfire-analyser
Version: 0.2.6
Summary: Python library for post-fire assessment and wildfire analysis using Google Earth Engine.
Author: Marcelo Camargo
License-Expression: MIT
Project-URL: Homepage, https://github.com/camargo-advanced/wildfire-analyser
Project-URL: Source, https://github.com/camargo-advanced/wildfire-analyser
Project-URL: Issues, https://github.com/camargo-advanced/wildfire-analyser/issues
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: geemap==0.36.6
Requires-Dist: geopandas==1.1.1
Requires-Dist: geedim==2.0.0
Requires-Dist: python-dotenv==1.0.1
Dynamic: license-file

# wildfire-analyser

Python project for analyzing wildfires in natural reserves.

## Installation and Usage

Follow the steps below to install and test `wildfire-analyser` inside an isolated environment:

```bash
mkdir /tmp/test
cd /tmp/test

python3 -m venv venv
source venv/bin/activate

pip install wildfire-analyser
```

### Required Files Before Running the Client

Before running the client, you **must** prepare two items:

---

#### **1. Add a GeoJSON polygon**

Create a folder named `polygons` in the project root and place your ROI polygon file inside it:

```
/tmp/test/
├── polygons/
│   └── your_polygon.geojson
└── venv/
```

An example GeoJSON file is available in the repository.

---

#### **2. Create the `.env` file with GEE authentication data**

In the project root, add a `.env` file containing your Google Earth Engine authentication variables.

A `.env` template is also available in the GitHub repository.

```
/tmp/test/
├── .env
├── polygons/
└── venv/
```

---

### Running the Client

After adding the `.env` file and your GeoJSON polygon:

```bash
python3 -m wildfire_analyser.client \
   --roi polygons/canakkale_aoi_1.geojson \
   --start-date 2023-07-01 \
   --end-date 2023-07-21 \
   --deliverables-all \
   --days-before-after 1
```

Possible options for --deliverables are:
   RGB_PRE_FIRE,
   RGB_POST_FIRE,
   NDVI_PRE_FIRE,
   NDVI_POST_FIRE,
   NBR_PRE_FIRE,
   NBR_POST_FIRE,
   DNDVI,
   DNBR,
   RBR,
   BURN_SEVERITY_MAP,
   RGB_PRE_FIRE_VISUAL,
   RGB_POST_FIRE_VISUAL,
   DNBR_VISUAL,
   RBR_VISUAL,
   BURN_SEVERITY_VISUAL,
   BURNED_AREA_STATISTICS,

   
This will start the analysis process, generate visual thumbnail links for use by the frontend, and save the scientific GeoTIFF images to the GCP bucket.
All links will be displayed in the terminal.

for help, type:

```bash
python3 -m wildfire_analyser.client --help
```

You should see something like this:

```bash
usage: client.py [-h] --roi ROI --start-date START_DATE --end-date END_DATE
                 [--deliverables DELIVERABLES [DELIVERABLES ...]] [--deliverables-all]
                 [--days-before-after DAYS_BEFORE_AFTER]

Post-fire assessment using Google Earth Engine

options:
  -h, --help            show this help message and exit
  --roi ROI             Path to ROI GeoJSON file
  --start-date START_DATE
                        Start date (pre-fire) in YYYY-MM-DD format
  --end-date END_DATE   End date (post-fire) in YYYY-MM-DD format
  --deliverables DELIVERABLES [DELIVERABLES ...]
                        List of deliverables to generate. Example: --deliverables RGB_PRE_FIRE DNBR
  --deliverables-all    Generate all available deliverables
  --days-before-after DAYS_BEFORE_AFTER
                        Number of days before and after the event date to search imagery (default: 30)
```

## Setup Instructions for Developers

1. **Clone the repository**

```bash
git clone git@github.com:camargo-advanced/wildfire-analyser.git
cd wildfire-analyser
```

2. **Create a virtual environment**

```bash
python3 -m venv venv
```

3. **Activate the virtual environment**

```bash
source venv/bin/activate
```

4. **Install dependencies**
   Make sure the virtual environment is activated, then run:

```bash
pip install -r requirements.txt
```

5. **Configure environment variables**
   Copy your version of `.env` file to the root folder with your GEE authentication credentials. A template file `.env.template` is provided as an example.

6. **Run the sample client application**

```bash
python3 -m wildfire_analyser.client \
   --roi polygons/canakkale_aoi_1.geojson \
   --start-date 2023-07-01 \
   --end-date 2023-07-21 \
   --deliverables-all \
   --days-before-after 1
```

## Useful Commands

* **Deactivate the virtual environment**:

```bash
deactivate
```

* **Build a new PyPi lib and publish **:

```bash
rm -rf dist/*
python -m build
twine upload dist/*
```
