Skip to content

digitalearthpacific/dep-veg

Repository files navigation

Vegetation Height Estimation Product for the Pacific Region

This repository contains the code developed to produce vegetation height map from aerial RGB input. This is an alpha product developed by Geoneon Pty Ltd in collaboration with Digital Earth Pacific (DEP). The vegetation height map can be viewed here.

Table of Contents


Overview

This project provides an end-to-end pipeline for estimating vegetation height at 10-meter resolution from RGB satellite imagery, with a focus on large-scale monitoring across the Pacific region. The goal is to enable consistent, scalable vegetation structure mapping in areas where traditional height measurements (e.g. LiDAR or field surveys) are sparse, costly, or unavailable.

Vegetation height is defined as the mean height of all above-ground vegetative elements within each 10 m pixel, including grasses, shrubs, and tree canopies. Non-vegetated surfaces are treated as zero height; note that this concerns average height, so maximum or canopy-top height is not estimated.

The pipeline uses RGB composites from Sentinel-2–derived products—specifically GeoMAD annual composites or Copernicus Quarterly Cloudless Mosaics—as inference inputs. A deep learning model is trained using a two-stage approach:

A high-resolution (1 m) vegetation height model trained on LiDAR-derived labels, and a 10 m model trained on downsampled real labels and pseudo-labels generated at scale from the 1 m predictions.

To ensure robust inference across diverse conditions, the pipeline includes preprocessing steps such as land/ocean masking and color normalization, followed by tiled inference and reassembly into seamless height maps. The resulting products enable applications such as deforestation and recovery detection, vegetation change monitoring, and large-area biomass analysis, with quarterly updates possible when using Cloudless Mosaic inputs.

Related Materials

All related documents for this project are in the DEP Google Drive:

https://drive.google.com/drive/folders/10tincZwUIPo59KID83KBy5fDiDqPK-2Q

In this folder, important materials include:

  • Methodology report:

https://drive.google.com/file/d/1szraqLC2I5dNwKhCnp7SYjxz_mo9_Cf8/view?usp=drive_link

  • Validation with GEDI data in the Pacifics:

https://drive.google.com/drive/folders/1np0DiDYyijn-bhHrs08PwizqgnusBCFe?usp=drive_link

  • Brian Killough's analysis to compare our results on GeoMAD data with other deforestation detection methods:

https://docs.google.com/presentation/d/1CxmC_BUGnGrc5soMC4eROb9excqYXYgG/edit?usp=drive_link&ouid=118390438972861404603&rtpof=true&sd=true

Getting Started

Installation

It is recommended to use the Docker Image in this repo to set up the working environment. Only this method has been tested. In the container, the repo directory is /code/. All dependencies are already installed in the container's root python environment - no further virtual environment is required.

src/run_task.py automatically downloads the models for you. If you don't run it (due to credential issues), the models can be found here

Usage

To use the code, one needs to create a .env file from the .env_example file and fill in the credentials. The CDSE credentials can be obtained by creating an account and generate the credentials as instructed here. These environment credentials will be registered in src/run_task.py

There are 2 ways one can make use of the code in this repo:

  • The official way is to run python src/run_task.py with appropriate arguments:

Here is an example command to run height inference on a tile whose id=107,8 then the results are saved into the STAC document at https://dep-public-staging.s3.us-west-2.amazonaws.com/dep_s2_vegheight/1-0-6-alpha/107/008/2024-10--P3M/dep_s2_vegheight_107_008_2024-10--P3M.stac-item.json

python src/run_task.py --tile-id 107,8 --version 1.0.6-alpha --output-bucket dep-public-staging --collection-url-root https://stac.staging.digitalearthpacific.io/collections --datetime 2024-10-01

NOTE: datetime can be a year (2024) or a period between years (2023-2024) or a specific date (YYYY-MM-01) where MM must be within {01, 04, 07, 10}. Data is only available at quarterly start dates. If data isn't available, the code simply exits.

  • The other way is to open a new Jupyter Notebook and use the components in src/utils.py to run inference according to your needs. The file TestProcessor.ipynb is a notebook where many experiments took place during development. It may provide useful hints for further customized usage.

Project Structure

Here is a top-down description of important components:

  1. src/run_task.py or TestProcessor.ipynb are the main files to run. The former writes results to DEP AWS so the latter is preferred for development.
  2. Within them, the credentials from .env file are registered to interact with AWS for both data loading and result writing
  3. A Processor is initiated. This can be either VegProcessor or VegProcessorKeepNonVegPixels. These are the core of the inference process that handles all calculations. During this step, the necessary models are downloaded and loaded into GPU.
  4. The input data is lazily loaded as a xarray dataset with bands "red", "green", "blue" or "B04", "B03", "B02"
  5. That data is fed into the Processor where it will be loaded and processed.
  6. The Processor returns xarray datasets as results.
  7. These results may be written to DEP AWS via DEP tools already installed in the container.

The project is structured to run in Argo as follows:

First, we run python src/print_tasks.py to output the tile ids. Then for each tile id, a node running python src/run_task.py is spawned and finishes with results saved in DEP AWS account.

Other information:

location to upload new models in the future: https://us-west-2.console.aws.amazon.com/s3/upload/dep-public-staging?region=us-west-2&bucketType=general&prefix=dep_s2_vegheight/models/

current model download link:

https://dep-public-staging.s3.us-west-2.amazonaws.com/dep_s2_vegheight/models/dep-veg-model-v2.zip

About

Vegetation structure

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages