Inspiration

Cotton Field Detector: Project Documentation

Arnav Sharma
UIN: 934005811


Project Overview

The Cotton Field Detector is a web-based tool developed to identify and map cotton fields within a specified Area of Interest (AOI) using satellite data, environmental indices, and machine learning. This tool leverages publicly available datasets from Google Earth Engine (GEE) to classify areas where cotton is being cultivated, providing insights into agricultural land use and potentially assisting in crop management.


Development Process

Concept and Requirements Gathering

  • Objective: Detect cotton fields based on satellite imagery and environmental factors.
  • Focus Area: Initially focused on the U.S., with plans to scale to any geographical location with accessible data.
  • Features and Functionality:
    • User inputs AOI through geographic coordinates.
    • Application classifies and displays regions likely to have cotton fields.

Selecting Tools and Libraries

  • Google Earth Engine (GEE): For satellite data processing and environmental analysis.
  • Flask: To build a simple, web-based interface for user interaction.
  • Python: For data manipulation and server-side scripting.

Building the Web Interface

  • Created a user-friendly form with HTML and CSS, using Flask templating to accept AOI coordinates.
  • Developed a map display area to show classified regions overlaid on an interactive map using Leaflet.js.

Integrating Earth Engine

  • Established authentication and initialization for Google Earth Engine within the Flask application.
  • Developed functions for data retrieval, processing, and exporting results from GEE.

Testing and Iteration

  • Tested with various AOI coordinates (initially in the U.S.) to validate output.
  • Refined the classification model and sampling process based on results.
  • Adjusted map functionality to display accurate classifications and center on the selected AOI.

Datasets Used

USDA/NASS Cropland Data Layer (CDL)

  • Source: USDA
  • Description: Annual crop-specific land cover data for the United States. Used the 2023 data, selecting the "cropland" band to identify various crop types.
  • Purpose: Created a mask for cotton fields (labeled with integer code 2) to use as our classification label.

Landsat 8 Surface Reflectance (LANDSAT/LC08/C02/T1_L2)

  • Source: NASA/USGS
  • Description: Multispectral imagery with bands for red, blue, green, near-infrared, and shortwave infrared.
  • Purpose: Calculated vegetation indices (NDVI, EVI, NDMI) for detecting vegetation health and moisture, used as features in the machine learning model.

NASA/ORNL DAYMET V4 Daily Surface Weather Data

  • Source: NASA ORNL
  • Description: Daily temperature data for North America. Used the "tmax" and "tmin" bands for maximum and minimum temperatures.
  • Purpose: Added environmental context to vegetation indices to improve classification based on growth conditions.

Model Training Process

Defining the Features and Labels

  • Features: NDVI, EVI, NDMI, Tmax, and Tmin, calculated within the AOI.
  • Label: Cotton mask derived from the CDL dataset, identifying cotton fields with a specific integer code.

Data Sampling

  • Sampling: Sampled pixels from the dataset at a scale of 30 meters within the AOI.
  • Sample Size: Limited to 5000 pixels per AOI for efficiency and accuracy.
  • Random Seed: Set for reproducibility of training data.

Training the Model

  • Used the smileRandomForest classifier in GEE with 100 trees for model stability.
  • Model trained on sampled features and labels, learning characteristics of cotton fields based on input features.

Classification and Smoothing

  • Classified pixels within the AOI using the trained model.
  • Applied focal mode smoothing to reduce noise, making the classification map visually coherent.

Validation

Visual Comparison

  • Compared model output with known cotton-growing areas (e.g., Lubbock, TX, and Tifton, GA) to confirm accurate classification of cotton fields.

Accuracy Assessment (Future Scope)

  • Future validation could include ground-truth data (e.g., USDA datasets) to quantify accuracy.
  • Metrics like Overall Accuracy, Precision, and Recall for cotton classification could provide insight into model reliability.

Front-End User Interface

User Input

  • User enters AOI coordinates as four latitude-longitude values (bounding box).
  • Upon submission, the system retrieves and processes data for the specified AOI.

Display of Results

  • Map displays classified regions in red, highlighting detected cotton fields within the AOI.
  • Map recenters based on AOI input for an intuitive interface.

Error Handling and Feedback

  • Provides feedback if user input is invalid or if classification fails.
  • User-friendly design with straightforward navigation and result interpretation.

Future Improvements

Extended Dataset Integration

  • Add additional environmental data (e.g., precipitation, soil moisture) for improved accuracy.

Model Generalization

  • Test and refine the model for performance outside the U.S.
  • Use transfer learning or retraining in regions with different climates for adaptability.

Performance Optimization

  • Improve data processing for larger AOIs and reduce response time.

Automated Validation Pipeline

  • Create a validation pipeline for real-time accuracy metrics using validation points or known datasets.

Enhanced User Interface

  • Add functionalities like zooming, custom AOI drawing, and result exporting directly from the web app.

What it does

How we built it

Challenges we ran into

Accomplishments that we're proud of

What we learned

What's next for TAMIDS

Built With

Share this project:

Updates