A comprehensive tool for processing climate, NDVI, fire history, and topographical data for machine learning-based forest fire prediction.
├── 📁 Data
│ ├── 📁 Grid # Shapefiles for each province
│ ├── 📁 FireHistory # Fire history dataset
│ ├── 📁 credentials # API credentials (🚨 Not included in the repository)
│
├── 📁 Output
│ ├── 📁 Requests # Stores all processed data per request
│ ├── 📁 Request_YYYYMMDD_HHMM
│ ├── 📁 Climate # Processed climate data
│ ├── 📁 FireHistory # Processed fire history data
│ ├── 📁 NDVI # NDVI data (raw + interpolated)
│ ├── 📁 Topography # DEM, slope, and aspect data
│ ├── 🗂 merged_data.csv # Final merged dataset
│
├── 📜 process_climate.py # Fetches & processes climate data
├── 📜 process_ndvi.py # Fetches & processes NDVI data
├── 📜 process_fire_history.py # Processes fire history data
├── 📜 process_topo.py # Fetches & processes topographical data
├── 📜 merge_data.py # Merges all processed data
├── 📜 main.py # Main script for execution
├── 📜 README.md # You're reading it! 📖
The CDS API (Copernicus Data Service) is required to fetch climate and topographical data. Follow these steps to set up your credentials:
- Go to the Copernicus Climate Data Store (CDS):
https://cds.climate.copernicus.eu/user/register - Register for an account and verify your email.
- Once logged in, go to My Account → API key.
Your CDS API key will look something like this:
url: https://cds.climate.copernicus.eu/api/v2
key: 12345678-abcd-1234-efgh-56789abcdefg
You need to store your API credentials in a hidden file .cdsapirc in your home directory.
- Open a terminal and run:
nano ~/.cdsapirc - Paste the following content, replacing
your-key:url: https://cds.climate.copernicus.eu/api/v2 key: 12345678-abcd-1234-efgh-56789abcdefg verify: 0 - Save and exit (
CTRL + X, thenY, thenENTER).
- Open Notepad and paste the API key in the same format as above.
- Save it as
.cdsapircinC:\Users\YourUsername\. - Make sure the file type is All Files (
*.*) and not.txt.
After setting up the credentials, verify they are working by running:
python -c "import cdsapi; c = cdsapi.Client(); print('CDS API setup successful!')"If there are no errors, your CDS API is correctly configured! ✅
-
Clone the repository:
git clone https://github.com/your-repo/forest-fire-tool.git cd forest-fire-tool -
Install dependencies:
pip install -r requirements.txt
-
Create the API credentials folder manually: The
Data/credentialsfolder is excluded from version control. Create it manually and add the required JSON files:├── 📁 Data │ ├── 📁 credentials │ ├── credentials.json # Contains API username & password │ ├── access_token.json # Stores generated access tokens -
Populate
credentials.jsonwith the following format:{ "username": "your_username", "password": "your_password" }
python main.pyIt will prompt you for:
- Province (e.g.,
"Alberta") - Start Date (
YYYY-MM-DD) - End Date (
YYYY-MM-DD)
This script will:
✅ Download & process climate, NDVI, fire history, and topographical data
✅ Merge everything into one structured CSV file
✅ Save results under Output/Requests/Request_YYYYMMDD_HHMM/
Each request generates a timestamped folder inside Output/Requests/.
Inside this folder, you'll find:
| GridID | Date | Wind Speed U | Wind Speed V | Temperature | Surface Pressure | Precipitation | Latitude | Longitude |
|---|---|---|---|---|---|---|---|---|
| 1 | 2023-05-01 | -0.37 | -0.27 | 276.23 | 80018.0 | 1.28e-06 | 53.34 | -119.68 |
| grid_id | Date | Total Fire Size | Fire Occurred | Fire Cause | Latitude | Longitude |
|---|---|---|---|---|---|---|
| 436 | 2023-05-01 | 6422.17 | 1 | Natural | 56.30 | -119.98 |
🚨 If no fire data is found for a grid,
Fire_Occurred = 0Total_Fire_Size = 0Fire_Cause = NaN
| grid_id | date | ndvi |
|---|---|---|
| 1 | 2023-05-01 | 0.34 |
| 2 | 2023-05-01 | 0.29 |
🚨 If no NDVI is found, NDVI = NaN
| grid_id | Latitude | Longitude | Elevation | Slope | Aspect |
|---|---|---|---|---|---|
| 1 | 53.34 | -119.68 | 962.05 | 35.0 | 161.71 |
🚨 If no data found, values will be NaN
| grid_id | Latitude | Longitude | Date | Climate Variables | Fire History | NDVI | Topography |
|---|---|---|---|---|---|---|---|
| 1 | 53.34 | -119.68 | 2023-05-01 | ✅ | ✅ | ✅ | ✅ |
| 2 | 53.43 | -119.74 | 2023-05-01 | ✅ | ❌ | ✅ | ✅ |
🚨 Missing values are handled as NaN for ML compatibility.
✅ Fix: Run the following command to create & store an access token:
python generate_token.py- Ensure all individual scripts ran successfully inside
Output/Requests/Request_YYYYMMDD_HHMM/ - If any data is missing, check logs and rerun that specific script.
✔ Add more weather variables like humidity & solar radiation
✔ Support larger regions by dividing grids dynamically
✔ Improve data interpolation for NDVI
Feel free to submit pull requests or report issues!
🚀 Developed by: Dheemanth
📅 Last Updated: 2025-02-03
This README should provide everything needed for new users to set up, run, and understand the tool. Let me know if you'd like any refinements! 🚀🔥