Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Kenya Habitat Similarity Mapping with Google Earth Engine and Geemap

Overview

This project visualizes known habitat observation sites and predicted similar habitat locations across Kenya using Google Earth Engine, Pandas, and Geemap.

The workflow: - Loads known positive and negative habitat sites from Excel files - Loads predicted habitat similarity points from a CSV file - Converts records into Earth Engine FeatureCollections - Styles predicted points based on Similarity Score - Displays all layers on an interactive map in Jupyter Notebook

This helps explore spatial patterns of habitat similarity and compare predicted habitats against known field observations.


Features

  • Google Earth Engine initialization and authentication
  • Automatic loading of similarity prediction CSV data
  • Importing known positive and negative habitat sites from Excel sheets
  • Automatic column detection for longitude, latitude, and date
  • Duplicate point removal
  • Conversion of tabular data into Earth Engine spatial features
  • Score-based styling of predicted habitat points
  • Interactive geospatial visualization using Geemap
  • Map legend for interpretation
  • Runs inside Jupyter Notebook

Technologies Used

  • Python
  • Pandas
  • Google Earth Engine (earthengine-api)
  • Geemap
  • Jupyter Notebook

Input Files

Similarity CSV

Example path:

SIMILARITY_CSV = "/Users/rs/Downloads/Kenya_Habitat_Similarity.csv"

Required columns:

  • Latitude
  • Longitude
  • Similarity Score

Optional columns:

  • Habitat ID
  • Chunk Index

Excel File 1

Example path:

FILE_1 = "/Users/rs/Downloads/positives & negatives kenya.xlsx"

Expected sheets:

  • Positives
  • Negatives

Excel File 2

Example path:

FILE_2 = "/Users/rs/Downloads/Kenya.xlsx"

Expected sheets:

  • Positive Sites
  • Negatve Sites

Note: The sheet name "Negatve Sites" must match the Excel sheet name used in the script.


Output

The script produces an interactive map displaying:

  • Blue points → Known positive habitat sites
  • Black points → Known negative habitat sites
  • Colored points → Predicted similar habitats

Similarity color classes:

Similarity Score Color Meaning


≥ 97 Dark Green Very high similarity 94--96.99 Lime Green High similarity 91--93.99 Orange Moderate similarity 88--90.99 Red Lower similarity


Installation

Install required packages:

pip install pandas geemap earthengine-api openpyxl

Google Earth Engine Setup

Authenticate Earth Engine:

import ee
ee.Authenticate()

Initialize with project:

PROJECT_ID = "interpolated"
ee.Initialize(project=PROJECT_ID)

How to Run

  1. Open the script in Jupyter Notebook
  2. Update file paths if necessary
  3. Run the cells sequentially
  4. The interactive map will display with:
Map

Script Workflow

1. Earth Engine Initialization

The script authenticates and initializes the Earth Engine API.

2. Data Loading

Reads similarity predictions from CSV and known sites from Excel sheets.

3. Data Standardization

Column names are standardized to identify longitude, latitude, date, and site ID.

4. Data Cleaning

Invalid coordinates are removed and duplicate points are dropped.

5. Kenya Boundary Extraction

Kenya's national boundary is obtained from:

FAO/GAUL/2015/level0

6. Conversion to Earth Engine Features

All rows are converted into spatial features using Earth Engine.

7. Map Styling

Predicted points are colored based on similarity score thresholds.

8. Map Visualization

Layers are added to the map including:

  • Kenya boundary
  • Known positive sites
  • Known negative sites
  • Predicted similar habitats

Example Use Cases

  • Habitat similarity analysis
  • Ecological site comparison
  • Environmental suitability visualization
  • Validation of predicted habitat clusters
  • Spatial comparison between observed and predicted habitats

Italy Habitat Similarity Mapping with Google Earth Engine and Geemap

Overview

This module visualizes known habitat observation sites and predicted environmentally similar locations across Italy using Google Earth Engine, Pandas, and Geemap.

The workflow:

  • Loads known habitat observation sites from an Excel dataset
  • Generates background sampling points across Italy
  • Extracts environmental predictors from Sentinel-2 satellite imagery
  • Trains a Random Forest model to identify environmental similarity
  • Displays predicted habitat similarity across Italy on an interactive map

This allows exploration of spatial patterns in environmental similarity and comparison between known observation sites and predicted suitable locations.


Features

  • Google Earth Engine initialization and authentication
  • Automatic loading of habitat observation coordinates from Excel
  • Generation of pseudo-absence background points
  • Sentinel-2 environmental predictor extraction
  • Terrain feature integration (elevation and slope)
  • Random Forest habitat similarity modeling
  • Interactive geospatial visualization using Geemap
  • Map legend and layered visualization
  • Runs inside Jupyter Notebook

Technologies Used

  • Python
  • Pandas
  • Google Earth Engine (earthengine-api)
  • Geemap
  • Jupyter Notebook
  • Sentinel-2 satellite imagery
  • NASA DEM terrain dataset

Input Files

Italy Habitat Excel File

Example path:

FILE_ITALY = "/Users/rs/Downloads/ITALY KML.xlsx"

Required columns:

  • Longitude
  • Latitude

Example columns detected automatically:

  • Longitudes
  • Latitudes

The script automatically standardizes column names and removes invalid or duplicate coordinates.


Output

The script produces an interactive map displaying:

  • Red points → Known habitat observation sites
  • Blue points → Background sampling points
  • Colored raster layer → Predicted environmental similarity

Probability map colors:

Probability Color
Low Black
Moderate Purple / Cyan
High Yellow
Very High Red

The map also includes a distance-from-training layer to indicate areas farther from known observations.


Installation

Install required packages:

pip install pandas geemap earthengine-api openpyxl

Google Earth Engine Setup

Authenticate Earth Engine:

import ee
ee.Authenticate()

Initialize with project:

PROJECT_ID = "interpolated"
ee.Initialize(project=PROJECT_ID)

How to Run

  1. Open the notebook or script in Jupyter Notebook
  2. Update file paths if necessary
  3. Run the cells sequentially
  4. The interactive map will display with:
Map

Script Workflow

1. Earth Engine Initialization

The script initializes the Earth Engine API and authenticates the user.


2. Data Loading

Coordinates are loaded from an Excel dataset containing Italy observation sites.


3. Data Standardization

Column names are cleaned and standardized to detect:

  • longitude
  • latitude
  • site ID

4. Data Cleaning

  • invalid coordinates are removed
  • duplicate observation points are dropped

5. Italy Boundary Extraction

Italy's national boundary is obtained from:

FAO/GAUL/2015/level0

This defines the region used for environmental prediction.


6. Background Sampling

Since the dataset contains presence-only observations, the script generates pseudo-absence background points randomly across Italy while avoiding areas near known observation sites.


7. Environmental Feature Extraction

Predictors are generated from Sentinel-2 imagery and terrain datasets.

Environmental variables include:

  • B2, B3, B4, B8, B11, B12 spectral bands
  • NDVI vegetation index
  • NDWI water index
  • MNDWI water detection index
  • NBR vegetation disturbance index
  • Elevation
  • Terrain slope

8. Model Training

A Random Forest classifier is trained using environmental predictors from:

  • known observation sites
  • background points

The dataset is split into:

  • 70% training
  • 30% testing

9. Model Evaluation

Model performance is evaluated using:

  • Accuracy
  • Precision
  • Recall
  • F1 Score
  • Cohen’s Kappa
  • Confusion matrix

These metrics help assess how well the model distinguishes observation sites from background environmental conditions.


10. Habitat Similarity Prediction

The trained model is applied across Italy to produce:

  • Habitat classification layer
  • Habitat probability surface
  • Distance-from-training diagnostic layer

These layers estimate locations with environmental conditions similar to the known observation sites.


Example Use Cases

This module can be used for:

  • Habitat similarity analysis
  • Environmental suitability visualization
  • Spatial comparison between observed and predicted sites
  • Ecological site exploration
  • Remote sensing–based habitat modeling

Notes

This model currently uses presence-only observations with pseudo-absence background sampling.

Therefore:

  • predictions represent environmental similarity estimates
  • results should be interpreted cautiously when extrapolating across large areas

For improved modeling, future work could include:

  • additional observation sites
  • true absence locations
  • spatial cross-validation
  • integration of climate or soil datasets

Possible Improvements

Potential enhancements include:

  • exporting maps to HTML
  • adding interactive point popups
  • clustering dense observation points
  • filtering predictions by probability threshold
  • integrating climate or land cover layers
  • adding regional or provincial boundaries

Relation to Kenya Module

This module extends the Interpolators project, which includes similar habitat similarity modeling workflows for multiple regions.

The Kenya module visualizes known sites and predicted habitat similarity across Kenya, while the Italy module demonstrates how the same modeling pipeline can be adapted to different geographic regions.


Author

Rishil Shah University of South Florida

Focus areas:

  • Machine Learning
  • Geospatial AI
  • Remote Sensing
  • Environmental Modeling

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages