Enhancing Orchard Management with Deep Learning: Tree Segmentation Using Geospatial SAM2 Model and Aerial Imagery
Authors: Sarbani Kumar, Mohammadreza Narimani, Ali Moghimi, Alireza Pourreza
Project Description
This repository is dedicated to the GeoSAM2 Tree Segmentation project, which utilizes advanced deep learning models for the segmentation of tree canopies from high-resolution aerial imagery. This project is conducted by the Digital Agriculture Laboratory at the University of California, Davis.
Our methodology involves marking each tree with rectangular bounding boxes to enhance the segmentation accuracy of the deep learning model. The deployment of SAM2 allows for precise delineation of tree boundaries and computation of each tree's area, offering essential data that directly correlates tree coverage with agricultural yields, fruit, and nut production, and overall biomass. This project not only promises to boost yield predictions and resource allocation but also supports the sustainable management of orchards, positioning it as an indispensable tool in agricultural technology.
This initiative is part of the ESEARCH program for Fall 2024 at UC Davis, where graduate students guide undergraduates through a 10-week research project. It aims to provide hands-on research experience and foster practical knowledge in emerging agricultural technologies.
Repository Structure
This repository is organized into multiple directories containing data, scripts, and results pertinent to the tree segmentation project:
- Data: Contains raw and processed datasets including aerial images, annotated datasets, and segmentation outputs.
-
Google Earth Engine Code: Scripts for processing data within the Google Earth Engine platform
(e.g.,
NAIP_Data_Downloader.js
). - Python Code: Jupyter notebooks and Python scripts for running the segmentation models, data analysis, and generating visualizations.
- Shapefiles: Geospatial data files used for mapping and spatial analysis.
- Poster: A folder containing a visual summary of the project.
Sample Code Snippet
Below is a short snippet from NAIP_Data_Downloader.js
, demonstrating how we load NAIP imagery
and allow users to draw polygons for area-specific downloads in Google Earth Engine:
// Import the NAIP dataset
var dataset = ee.ImageCollection('USDA/NAIP/DOQQ')
.filter(ee.Filter.date('2017-01-01', '2018-12-31'));
var trueColor = dataset.select(['R', 'G', 'B']);
// Visualize
Map.addLayer(trueColor, {min: 0, max: 255}, 'True Color');
// Export a clipped image to Google Drive
function exportImage(geometry) {
var clippedImage = trueColor.mosaic().clip(geometry);
Export.image.toDrive({
image: clippedImage,
description: 'NAIP_Exported_Image',
scale: 0.6,
region: geometry
});
}
Google Earth Engine Repository
To access and use the Google Earth Engine scripts associated with this project, clone our GEE repository:
https://code.earthengine.google.com/?accept_repo=users/mnarimani/UCDavis_ESEARCH_Fall_2024
Explore the App
Experience the application live: Deep Learning Tree Mapping Visualizer
Conference Poster
Check out the poster of this work that we presented at the ESEARCH program of UC Davis in the fall of 2024. Click on the image below to view the full PDF:

Acknowledgments
We extend our deepest gratitude to the Digital Agriculture Laboratory and the respective departments at UC Davis for providing resources and support. Special thanks to Dr. Qiusheng Wu and the Open Geospatial Solutions team for the segment-geospatial library, which has significantly contributed to the success of our project.
Contact Information
For more information, queries, or feedback regarding this project, please contact:
- Mohammadreza Narimani - mnarimani@ucdavis.edu
- Sarbani Kumar - srbkumar@ucdavis.edu
For more information about our lab and other projects, please visit Digital Agriculture Lab.