Instructions to use syifaazzhr/deforestation-analysis with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use syifaazzhr/deforestation-analysis with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://syifaazzhr/deforestation-analysis") - Notebooks
- Google Colab
- Kaggle
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
- Spatio-Temporal Deforestation Analysis Using Deep Learning
- 1. Project Overview
- 2. Research Problem
- 3. Project Objectives
- 4. Dataset
- 5. Tools & Technologies
- 6. Project Workflow
- 7. Satellite Image Preprocessing
- 8. Deep Learning Modeling
- 9. Model Evaluation
- 10. Spatio-Temporal Deforestation Analysis
- 11. Dashboard Visualization
- 12. How to Run
- 13. Project Limitations
- 14. Conclusion
- 1. Project Overview
Spatio-Temporal Deforestation Analysis Using Deep Learning
Land Cover Segmentation, Deep Learning Model Comparison, and Spatio-Temporal Deforestation Analysis
1. Project Overview
Deforestation is a major environmental challenge that affects biodiversity, ecosystems, and climate stability. Monitoring forest cover changes is essential for understanding deforestation patterns and supporting environmental management. This project implements deep learning-based satellite image segmentation to analyze land cover changes and identify deforestation in Riau Province, Indonesia, using Sentinel-2 imagery from 2019, 2022, and 2025. The study compares U-Net and Attention U-Net architectures with different loss functions to identify an effective land cover segmentation model. The selected model is then used to generate land cover maps, detect forest-to-non-forest transitions, quantify deforestation, and visualize the findings through an interactive dashboard.
2. Research Problem
Deforestation monitoring requires accurate spatial information and the ability to identify forest cover changes over time. However, satellite image segmentation faces several challenges:
- Spectral similarities between different land cover classes.
- Imbalanced pixel distributions across land cover categories.
- Cloud contamination and variations in satellite imagery.
- Differences between reference land cover data and satellite imagery.
- Difficulties in identifying and quantifying forest cover changes across different periods.
This project addresses two main research questions:
- How effectively can Attention U-Net perform land cover segmentation compared to U-Net?
- What deforestation patterns can be identified in Riau Province through spatio-temporal analysis of satellite imagery?
3. Project Objectives
- Prepare and preprocess Sentinel-2 satellite imagery for land cover segmentation.
- Develop and evaluate U-Net and Attention U-Net segmentation models.
- Compare different loss functions to identify the best-performing model.
- Evaluate segmentation performance using IoU, Dice Coefficient, and Sensitivity.
- Generate land cover maps for 2019, 2022, and 2025.
- Identify and quantify forest-to-non-forest transitions across observation periods.
- Analyze deforestation distribution across regencies and cities in Riau Province.
- Develop an interactive dashboard to visualize deforestation findings.
4. Dataset
This project uses Sentinel-2 Level-2A satellite imagery obtained through Google Earth Engine, covering Riau Province in 2019, 2022, and 2025. Land cover reference data from the Indonesian Ministry of Environment and Forestry (KLHK) were used as ground truth. The original reference categories were reorganized into seven land cover classes:
- Forest
- Planted Forest
- Plantation
- Other Vegetation
- Bare Land
- Built-up Area
- Water
The satellite imagery uses four spectral bands: Blue (B2), Green (B3), Red (B4), and Near Infrared (B8).
Dataset Preparation
- Patch Size: 256 Γ 256 pixels
- Total Dataset: 13,827 paired image and label patches
- Training Set: 9,678 patches (70%)
- Validation Set: 2,074 patches (15%)
- Testing Set: 2,075 patches (15%)
Patches were generated using a non-overlapping approach and retained when at least 50% of their pixels contained valid land cover labels.
5. Tools & Technologies
- Python: Data processing, deep learning, and analysis.
- U-Net & Attention U-Net: Deep learning architectures for semantic segmentation.
- Google Earth Engine: Satellite imagery acquisition and preprocessing.
- QGIS: Geospatial data processing and spatial analysis.
- Google Colab: Deep learning model development and training.
- Streamlit: Interactive dashboard development.
- GeoTIFF & Shapefile: Raster imagery and geospatial reference data.
6. Project Workflow
The project follows an end-to-end workflow combining satellite image processing, deep learning segmentation, and spatio-temporal analysis.
Data Collection β Satellite Image Preprocessing β Dataset Preparation β Deep Learning Modeling β Model Evaluation β Land Cover Segmentation β Deforestation Analysis β Dashboard Visualization
The main stages include:
- Collecting Sentinel-2 imagery and land cover reference data.
- Preprocessing satellite imagery using cloud masking and temporal compositing.
- Preparing image and label patches for model training.
- Training U-Net and Attention U-Net using different loss functions.
- Evaluating segmentation performance and selecting the best model.
- Generating land cover segmentation maps for each observation year.
- Identifying forest-to-non-forest changes and calculating deforestation areas.
- Presenting spatial and temporal findings through an interactive dashboard.
7. Satellite Image Preprocessing
Satellite imagery was preprocessed using Google Earth Engine to improve data quality before model training. The preprocessing stages included:
- Cloud Masking: Removing cloud-contaminated pixels using the Scene Classification Layer (SCL) and cloud probability data.
- Invalid Pixel Masking: Excluding no-data, defective, and other invalid pixels.
- Band Selection: Selecting B2, B3, B4, and B8 spectral bands.
- Temporal Compositing: Applying median compositing to combine observations from multiple acquisition dates.
- Raster Processing: Exporting imagery in GeoTIFF format and merging image tiles using QGIS.
These steps produced satellite imagery suitable for segmentation and subsequent spatial analysis.
8. Deep Learning Modeling
Two semantic segmentation architectures were evaluated:
- U-Net: Baseline convolutional neural network architecture.
- Attention U-Net: An enhanced U-Net architecture incorporating attention gates to selectively emphasize relevant spatial features.
Each architecture was trained using four loss functions:
- Dice Loss
- Focal Loss
- Weighted Focal Loss
- Tversky Loss
This resulted in eight model configurations.
Training Configuration
| Parameter | Configuration |
|---|---|
| Input Size | 256 Γ 256 Γ 4 |
| Batch Size | 8 |
| Optimizer | Adam |
| Learning Rate | 0.00005 |
| Maximum Epochs | 50 |
| Early Stopping | Enabled |
| Model Checkpoint | Enabled |
| Learning Rate Reduction | Enabled |
The models were evaluated using Intersection over Union (IoU), Dice Coefficient, and Sensitivity.
9. Model Evaluation
9.1 Model Comparison
The eight model configurations were evaluated on the testing dataset.
| Model | Loss Function | IoU | Dice Coefficient | Sensitivity |
|---|---|---|---|---|
| U-Net | Dice | 0.4833 | 0.6384 | 0.6452 |
| U-Net | Focal | 0.4937 | 0.6398 | 0.6190 |
| U-Net | Weighted Focal | 0.4651 | 0.6169 | 0.6658 |
| U-Net | Tversky | 0.4792 | 0.6346 | 0.6659 |
| Attention U-Net | Dice | 0.4881 | 0.6419 | 0.6590 |
| Attention U-Net | Focal | 0.4773 | 0.6193 | 0.6051 |
| Attention U-Net | Weighted Focal | 0.4814 | 0.6301 | 0.6241 |
| Attention U-Net | Tversky | 0.4949 | 0.6485 | 0.6767 |
Attention U-Net with Tversky Loss achieved the highest overall performance across the three evaluation metrics and was selected for land cover segmentation and deforestation analysis.
9.2 Best Model Performance by Land Cover Class
| Land Cover Class | IoU | Dice Coefficient | Sensitivity |
|---|---|---|---|
| Forest | 0.7812 | 0.8771 | 0.8977 |
| Planted Forest | 0.5855 | 0.7386 | 0.6994 |
| Plantation | 0.5393 | 0.7007 | 0.6699 |
| Other Vegetation | 0.3027 | 0.4648 | 0.4904 |
| Bare Land | 0.3953 | 0.5666 | 0.6435 |
| Built-up Area | 0.3407 | 0.5082 | 0.5895 |
| Water | 0.5196 | 0.6839 | 0.7466 |
The Forest class achieved the highest segmentation performance, while Other Vegetation was the most difficult to classify due to spectral similarities with Plantation areas.
10. Spatio-Temporal Deforestation Analysis
The best-performing model was used to generate land cover segmentation maps for 2019, 2022, and 2025. Deforestation was identified using post-classification comparison, focusing on pixels classified as Forest in the earlier observation and Non-Forest in the later observation. Deforestation areas were calculated through pixel-based area estimation and analyzed across administrative regions.
10.1 Deforestation Area
| Observation Period | Deforestation Area |
|---|---|
| 2019β2022 | 1,524.05 kmΒ² |
| 2022β2025 | 1,764.01 kmΒ² |
| Increase | 239.96 kmΒ² (15.74%) |
The analysis identified a 15.74% increase in the estimated deforested area between the two observation periods.
10.2 Regional Deforestation Patterns
The spatial analysis identified several regional patterns:
- Kampar Regency recorded the largest estimated deforestation area in both periods.
- Rokan Hilir Regency experienced the largest increase in deforestation between the two periods.
- Indragiri Hulu Regency recorded the largest decrease in estimated deforestation area.
- Deforestation patterns varied across the regencies and cities of Riau Province.
10.3 Forest Cover Transitions
The analysis examined land cover categories replacing previously forested areas.
| Forest Cover Transition | 2019β2022 (kmΒ²) | 2022β2025 (kmΒ²) |
|---|---|---|
| Forest β Planted Forest | 226.73 | 230.55 |
| Forest β Plantation | 270.17 | 265.02 |
| Forest β Other Vegetation | 914.24 | 1,101.05 |
| Forest β Bare Land | 82.67 | 141.42 |
| Forest β Built-up Area | 1.11 | 1.75 |
| Forest β Water | 29.13 | 24.22 |
The largest forest cover transition in both observation periods was from Forest to Other Vegetation, followed by Plantation and Planted Forest. These findings describe changes detected from the model-generated maps rather than independently verified land cover conversions.
11. Dashboard Visualization
An interactive dashboard was developed using Streamlit to present and explore the deforestation analysis results. The dashboard provides visualizations of land cover changes, deforestation distribution, and spatial patterns across observation periods.
12. How to Run
The project workflow involves preparing satellite imagery, running the trained segmentation pipeline, performing deforestation analysis, and exploring the dashboard.
- Clone the GitHub repository.
- Install the required Python dependencies.
- Configure dataset paths and the required environment.
- Run the satellite image preprocessing and dataset preparation scripts.
- Train or load the segmentation models.
- Generate land cover predictions and perform deforestation analysis.
- Launch the Streamlit dashboard to explore the results.
Specific commands depend on the available repository files and data configuration.
13. Project Limitations
- The study is limited to Riau Province and three observation years: 2019, 2022, and 2025.
- Land cover segmentation performance is affected by class imbalance and spectral similarities between categories.
- The ground truth was derived from reference land cover data with differences in spatial representation compared to Sentinel-2 imagery.
- Deforestation estimates depend on the accuracy of the predicted land cover maps.
- Pixel-based area calculations may contain estimation errors resulting from segmentation inaccuracies.
- Additional validation using higher-resolution imagery or field observations would improve the reliability of the findings.
14. Conclusion
This project demonstrates the application of deep learning and satellite imagery for land cover segmentation and spatio-temporal deforestation analysis in Riau Province. Attention U-Net with Tversky Loss achieved the best segmentation performance, with an IoU of 0.4949, Dice Coefficient of 0.6485, and Sensitivity of 0.6767. The resulting land cover maps were used to estimate deforestation, revealing a 15.74% increase in deforested area between the 2019β2022 and 2022β2025 observation periods. The project highlights how deep learning, remote sensing, and geospatial analysis can be integrated to support forest monitoring, while emphasizing the importance of segmentation accuracy and reference data quality when interpreting deforestation estimates.
- Downloads last month
- 404

