← Back to list

Unveiling Agricultural Transformation: Final Year Project on Change Detection in Farmlands Using…

Imagine witnessing the dynamic evolution of farmlands over time, capturing the subtle shifts and grand transformations that define modern…

Humna Zaidi · 2024-07-19 13:57 · 1,161 claps · 5.7 min read
#ndvi #ndbi #machine-learning #farmland #landsat8
Open on Medium ↗
Wiki topics: ML · Machine Learning CRY · Crypto & Web3 EDU · Education & Learning CUL · Culture & Media

Unveiling Agricultural Transformation: Final Year Project on Change Detection in Farmlands Using Landsat 8 Imagery

Imagine witnessing the dynamic evolution of farmlands over time, capturing the subtle shifts and grand transformations that define modern agriculture — this project unlocks those insights using cutting-edge satellite technology.

If you require the complete code for this project, please let me know, and I’ll be happy to provide it.

Abstract

This project conducts a comparative evaluation of well-established conventional methodologies using different vegetation indices to identify changes in agricultural regions of the USA via Landsat 8 imagery. We use NDVI, NDBI, and NDWI to preprocess multispectral images, creating composite images for training and testing data. Conventional machine learning models like SVM, Random Forest, and k-nearest neighbors are trained for supervised classification tasks. The integration of models with vegetation indices provides insights into vegetation dynamics. Evaluation metrics such as accuracy, precision, recall, and F1 score are used to assess model performance.

Introduction

This project evaluates various vegetation indices (NDVI, NDBI, NDWI) to detect changes in U.S. farmlands using Landsat 8 imagery. By integrating machine learning models (SVM, Random Forest, k-nearest neighbors). It enhances agricultural monitoring for sustainability and productivity.

DataSet

In this project we are using the landsat-8 imagery data of the USA and focus on the area between lebanon , stringfield and mountain home (2015 and 2020 year data) downloaded from earth explorer website Dataset Link : EarthExplorer (usgs.gov)

Normalized Differences

Normalized difference indices are mathematical formulas used in remote sensing to highlight specific qualities in satellite imagery. They provide numerical indicators to quantify vegetation and band composition, producing composite images for interpretation. This experiment uses NDVI, NDWI, and NDBI indices.

NDVI: The Normalized Difference Vegetation Index (NDVI) uses Near-Infrared (NIR) and Red bands. Calculated as

NDVI=(NIR-R)/(NIR+R)

It ranges from -1 to 1, with higher values indicating healthier vegetation. Landsat 8 uses Band 4 (Red) and Band 5 (NIR).

NDBI: The Normalized Difference Built-up Index (NDBI) detects urban areas. Calculated as

NDBI=(SWIR-NIR)/(SWIR+NIR)

It ranges from -1 to 1, with positive values indicating built-up areas. Landsat 8 uses Band 7 (SWIR) and Band 5 (NIR).

NDWI: The Normalized Difference Water Index (NDWI) identifies water bodies. Calculated as

NDWI = (G-NIR)/(G+NIR)

It ranges from -1 to 1, with positive values indicating water. Landsat 8 uses Band 3 (Green) and Band 5 (NIR).

Classification Models

We employed the following machine learning models to handle the multiclass classification of farm area change within a supervised and unbalanced dataset:

  • Support Vector Machines (SVM): Finds the optimal decision boundary by maximizing the margin between classes.
  • K-Nearest Neighbors (KNN): Classifies a data point based on the majority class of its nearest neighbors.
  • Random Forest: Builds multiple decision trees and predicts the class by averaging or majority voting, effective for high-dimensional data.

These models are selected for their flexibility in managing complex decision boundaries and handling unbalanced data.

Implementation

Data Pre-Processing: After reading images in the first step is to prepare data for further analysis, the landsat8 downloaded images were tilled and have extra black area which can affect the end results so we rotate the all landsat8 band images and then we cropped the extra black area from all of them.

Vegetation Index Calculation: After applying pre-processing on landsat8 band images, the next step is to calculate vegetation indexes and percentage of vegetation per year for each index

The above image shows the calculated percentage of each year data using vegetation indexes. The NDVI shows a higher percentage for 2020 year as compare to 2015 which indicate the increase in vegetation.The decrease in NDWI vegetation percentage from 2015 (76.19%) to 2020 (72.27%) shows a potential decrease in water-rich or moist vegetation areas. The Ndbi calculated percentage decrease shows increase in man made structure or alter urban structures.

NDWI FOR 2020 DATA SET

NDWI FOR 2020 DATA SET

To complement the tabular results, we can visualize the NDVI, NDBI, and NDWI findings for 2020.

Feature Extraction: Vegetation indices, typically single-channel, assess vegetation health. To analyze farmland changes, we create a three-channel dataset by combining NDVI with the green and blue bands. Adding the green band enhances farmland detection. Below is the code to stack NDVI with the green and blue bands:

combined_image_ndvi2015 = np.stack((ndvi2015,green2015,blue2015), axis=-1)
combined_image_ndvi2020 = np.stack((ndvi2020,green,blue),axis=-1)
combined_image_ndbi2015 = np.stack((ndbi2015,green2015,blue2015),axis=-1)
combined_image_ndbi2020 = np.stack((ndbi2020,green,blue), axis=-1)
combined_image_ndwi2015 = np.stack((ndwi2015,green2015,blue2015),axis=-1)
combined_image_ndwi2020 = np.stack((ndwi2020,green,blue),axis=-1PY

Above image presents a collection of composite images extracted from the original dataset. These images are superimposed onto the RGB image patch, enhancing clarity and 21 Unset facilitating a better understanding of the modifications made for model training and testing.

Handle Missing Values and Scaled: SimpleImputer is a class used to handle missing values in this project with strategy of mean

StandardScaler is scikit-learn class used for standardizing features by removing the mean values and scaling to unit variance

imputer = SimpleImputer(strategy='mean')
ndbi_combined_imputed = imputer.fit_transform(ndbi_combined)
scaler = StandardScaler()
ndbi_combined_scaled = scaler.fit_transform(ndbi_combined_imputed)

This step is very important in machine learning for preparing training and testing data set

PCA: After data extraction we applied PCA on the data set to reduce the data dimensions because the data set is very large (6555, 12524, 3) and to improve the performance here we applied the 1000n component selection PCA. In order to ensure that we have sufficient data combinations for training and testing for multiclass classification, 1000n components were chosen.

Data Labelling: After reducing the dimensions, the subsequent step involves creating ground truth labels for each dataset combination.

Train and Test Dataset: Once composite images are generated for each dataset and labelled accordingly, the subsequent stage involves dividing the dataset into two subsets: one for training the model and the other for testing its performance.

X_ndvi_train, X_ndvi_test, y_ndvi_train, y_ndvi_test = train_test_split(ndvi_reduced, ndvi_labels,
test_size=0.2, random_state=42)
X_ndbi_train, X_ndbi_test, y_ndbi_train, y_ndbi_test = train_test_split(ndbi_reduced, ndbi_labels,
test_size=0.2, random_state=42)
X_ndwi_train, X_ndwi_test, y_ndwi_train, y_ndwi_test = train_test_split(ndwi_reduced, ndwi_labels,
test_size=0.2, random_state=42)

Model and Training and Testing: Datasеt division, training thе modеl on thе training datasеt is crucial. This process involves fееding thе modеl with labeled data to lеarn pattеrns and rеlationships. Subsеquеntly, tеsting thе trainеd modеl using thе separate testing datasеt еvaluatеs its pеrformancе and gеnеralizability to nеw, unsееn data. In this step we trained 7model combinations

SVM+NDBI,

SVM+NDWI+SVMNDVI

RANDOM FOREST+NDVI,

RANDOM FOREST+NDBI,

RANDOM FOREST+NDWI KNN+NDVI,

KNN+NDBI,

KNN+NDW

Machine Learning Model Results

Confusion Matrix

Confusion Matrix

The confusion matrix plot in above vividly illustrates the superior performance of the random forest classifier. It notably showcases significantly low rates of incorrect predictions across classes, demonstrating its exceptional ability to accurately classify datasets indicating increase, decrease, and stability over time.

To distinctly demonstrates that the combination of random forest with the (NDBI, green, blue) bands yields the highest accuracy in detecting vegetation increase and decrease within farmland.

This project demonstrates the powerful synergy between Landsat 8 imagery and advanced machine learning techniques to monitor and analyze agricultural transformations. By leveraging vegetation indices and sophisticated classification models, we gain valuable insights into the evolving landscape of U.S. farmlands. The results not only underscore the effectiveness of these approaches but also highlight their potential for enhancing agricultural sustainability and productivity.

Should you have any further questions or require additional details, including the complete code for this project, please feel free to reach out.


메타데이터
post_id
6f02bbfe2b91
slug
unveiling-agricultural-transformation-final-year-project-on-change-detection-in-farmlands-using-6f02bbfe2b91
url
https://medium.com/@humna.zaidi/unveiling-agricultural-transformation-final-year-project-on-change-detection-in-farmlands-using-6f02bbfe2b91
canonical_url
https://medium.com/@humna.zaidi/unveiling-agricultural-transformation-final-year-project-on-change-detection-in-farmlands-using-6f02bbfe2b91
author_url
https://medium.com/@humna.zaidi
status
ok
fetched_at
2026-06-20 20:29:01