A place to create and share code of newly made maps of canopy tree heights.
Meta and the World Resources Institute launched a global map of tree canopy height at a 1-meter resolution, allowing the detection of single trees on a global scale. Both the canopy height data and the models used to create the data are free and publicly available (Tolan, Couprie, et al. 2024). The maps were created using machine learning models on high-resolution worldwide Maxar satellite imagery. The details of the model used to create the data set are described in Tolan et al. (2024).
Download R/RStudio at this link: https://posit.co/download/rstudio-desktop
A great resource for using basemaps in R to produce the interactive maps using Leaflet, Carto, and TESS-Laboratories:
Leaflet: https://github.com/Leaflet/Leaflet
Carto: https://github.com/CartoDB/basemap-styles
TESS-Laboratories: https://github.com/TESS-Laboratory/chmloader
This repository includes a comprehensive Docker container that provides all the necessary dependencies and tools for tree canopy height mapping analysis. The container is built on the rocker/geospatial base image and includes R 4.2.2 with pre-installed packages.
Option 1: Pull from GitHub Container Registry (Recommended)
docker pull ghcr.io/geodegarmo/treeheightmaps_r:latest
docker run --rm -it ghcr.io/geodegarmo/treeheightmaps_r:latestOption 2: Build Locally
# Clone the repository
git clone https://github.com/geodegarmo/treeHeightMaps_R.git
cd treeHeightMaps_R
# Build the Docker image
docker build -t treeheightmaps .
# Run the container
docker run --rm -it treeheightmapsThe Docker container includes:
- R 4.2.2 with optimized geospatial libraries
- Pre-installed packages:
terra,sf,tidyverse,leaflet,htmlwidgets,ggplot2 - Example scripts ready to run in the
/app/example/directory - Helper scripts for getting started and package installation
- Comprehensive documentation accessible within the container
The container comes with these key packages pre-installed:
terra- For raster data processing and spatial analysissf- For vector spatial data handlingtidyverse- For data manipulation and visualizationleaflet- For interactive mappinghtmlwidgets- For creating HTML-based visualizationsmaptiles- For downloading map tilestidyterra- For terra integration with tidyverseclassInt- For class interval calculations
Interactive R Session:
docker run --rm -it treeheightmapsRun a Specific Script:
docker run --rm -v $(pwd)/data:/app/data treeheightmaps R -e "source('example/tree_canopy_height_1m.R')"Mount Local Directories:
# Mount data and output directories
docker run --rm -it \
-v $(pwd)/data:/app/data \
-v $(pwd)/output:/app/output \
treeheightmapsUsing Docker Compose:
# Start the container with volume mounts
docker-compose up treeheightmaps
# Or start RStudio Server on http://localhost:8787
docker-compose up rstudioThe example scripts now automatically handle the installation of required packages, including the chmloader package from TESS-Laboratory. When you run an example script for the first time, it will automatically:
- Install
devtoolsandpacmanif not already present - Install the
chmloaderpackage from GitHub if not already installed - Install an updated version of
leafletif needed
Manual Installation (if needed):
# Inside the container or R session
install.packages("devtools")
devtools::install_github("TESS-Laboratory/chmloader")Note: An internet connection is required for GitHub package installation.
When you start the container, it automatically displays:
- Available example scripts
- Installed package status
- Getting started instructions
To run the examples:
# List available scripts
list.files("example")
# Run an example (modify coordinates as needed)
source("example/tree_canopy_height_1m.R")Make a directory and then clone the github.
In Terminal:
mkdir globalTreeHeight && git clone https://github.com/geodegarmo/treeHeightMaps_R.git
Tolan, Jamie, Camille Couprie, John Brandt, Justine Spore, Tobias Tiecke, Tracy Johns, and Patrick Nease. 2024. “Using Artificial Intelligence to Map the Earth’s Forests.” Meta Sustainability. https://sustainability.fb.com/blog/2024/04/22/using-artificial-intelligence-to-map-the-earths-forests/.
Tolan, Jamie, Hung-I Yang, Benjamin Nosarzewski, Guillaume Couairon, Huy V. Vo, John Brandt, Justine Spore, et al. 2024. “Very High Resolution Canopy Height Maps from RGB Imagery Using Self-Supervised Vision Transformer and Convolutional Decoder Trained on Aerial Lidar.” Remote Sensing of Environment 300 (January): 113888.
https://doi.org/10.1016/j.rse.2023.113888.