CoolFace
Apppublic

Wampu204/farmlenz

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
App README

NDVI-Based Field Segmentation

![Streamlit](https://streamlit.io) ![License: MIT](LICENSE)

A web application for analyzing agricultural fields using satellite imagery and NDVI (Normalized Difference Vegetation Index) data to create management zones for precision agriculture like zoning based on yield of the field areas.


Table of Contents


Overview

This application leverages Google Earth Engine and Sentinel-2 imagery to compute NDVI values across agricultural fields. By clustering field pixels into management zones, farmers and agronomists can make data-driven decisions on irrigation, fertilization, and pest management.

Key capabilities include:

  • Computation of median NDVI over a selected date range
  • Integration of daily rainfall (CHIRPS) to correlate weather with crop health
  • Customizable clustering algorithms
  • Time-series visualization of vegetation dynamics

Features

  • Interactive Field Selection: Input latitude, longitude, and radius to define the target field.
  • Multiple Clustering Methods: K-Means, DBSCAN, Mean Shift, or Gaussian Mixture Models (GMM).
  • NDVI Time Series Analysis: View historical NDVI trends for monitoring crop development.
  • Rainfall Data Integration: Overlay precipitation patterns to diagnose water stress.
  • Crop-Specific Insights: Tailor analysis to crop type and growth stage.
  • Downloadable Reports: Export CSV and PDF summaries of zone statistics and time-series data.
  • Algorithm Comparison: Side-by-side evaluation of clustering outcomes.
  • Interactive Maps: Color-coded maps of NDVI and management zones.
  • Parameter Tuning: Adjust time window, clustering parameters, and data thresholds.

Installation

Prerequisites

  • Python 3.7 or higher
  • Google Earth Engine account
  • Streamlit

Setup

  1. 1.Clone the repository:
bash
   git clone https://github.com/Priyam-28/CropSight.git
   cd ndvi-field-segmentation
  1. 1.Install dependencies:
bash
   pip install -r requirements.txt
  1. 1.Authenticate Earth Engine:
bash
   earthengine authenticate

Usage

  1. 1.Launch the app:
bash
   streamlit run app.py
  1. 1.In the browser UI:
  2. 2.Enter your field’s latitude and longitude.
  3. 3.Specify a radius (in meters) around the point.
  4. 4.Choose a date range for analysis.
  5. 5.Select your crop type and growth stage.
  6. 6.Pick a clustering algorithm and adjust its parameters.
  7. 7.Click Analyze Field.
  1. 1.Navigate tabs:
  2. 2.NDVI Map: Visualize spatial NDVI distribution.
  3. 3.Field Zones: Explore segmented management zones.
  4. 4.Time Series: Inspect NDVI trends over time.
  5. 5.Rainfall: Check precipitation alongside NDVI.
  6. 6.Analysis: View statistics and tailored recommendations.
  7. 7.Comparison: Compare multiple clustering outputs.

Technical Details

Data Sources

  • Sentinel-2 (10 m resolution) for imagery.
  • CHIRPS daily precipitation dataset.

Processing Workflow

  1. 1.Fetch Sentinel-2 image collection for selected dates.
  2. 2.Compute NDVI for each scene: (NIR - RED) / (NIR + RED).
  3. 3.Aggregate to median NDVI mosaic.
  4. 4.Cluster pixel values into zones using chosen algorithm.
  5. 5.Extract NDVI & rainfall time series for the field.
  6. 6.Generate statistics (mean, std, zone area) and insights.

Clustering Options

AlgorithmDescription
K-MeansFast, requires preset # of clusters
DBSCANDensity-based, auto-detects clusters and outliers
Mean ShiftMode-seeking, no need for cluster count
GMMProbabilistic, handles overlapping clusters

Screenshots

Select Crop and Field

[image]

Field Zones

[image]

NDVI Time Series

[image]

Rainfall Analysis

[image]


Example Use Cases

  1. 1.Variable Rate Application: Generate prescription maps for targeted inputs.
  2. 2.Irrigation Management: Detect water-stressed zones for optimized watering.
  3. 3.Yield Estimation: Correlate NDVI patterns with expected yield.
  4. 4.Problem Spotting: Identify underperforming patches for intervention.
  5. 5.Seasonal Tracking: Monitor crop growth throughout the season.

Contributing

Contributions welcome! Please follow these steps:

  1. 1.Fork the repo and create a branch: git checkout -b feature/YourFeature
  2. 2.Commit your changes: git commit -m "Add new feature"
  3. 3.Push to your branch: git push origin feature/YourFeature
  4. 4.Open a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Acknowledgments

  • Google Earth Engine for satellite data access.
  • Sentinel-2 mission for high-resolution imagery.
  • CHIRPS for global precipitation datasets.
  • Streamlit for the interactive UI.