A linux command-line tool for fetching Meta's 1m Global Canopy Height data and derived forest mask for a specified Area of Interest.
This script uses a cloud-optimized workflow to stream data directly from the public AWS S3 bucket, returning a clipped Canopy Height raster and a corresponding binary forest mask as tiffs based on a user input bounds, .tif, or .geojson with input and output CRS control.
The 1m Global Canopy Height Maps dataset referenced is a collaboration between Meta and the World Resources Institute.
It's important to note two key characteristics of the data accessed by this script:
- The data is the 8-bit integer version hosted on AWS, with values representing canopy height in meters
- The dataset has a reported global accuracy of 2.8 meters for canopy height
For more information, interactive viewing, and tutorials, please see these excellent resources:
- Data Source: Registry of Open Data on AWS
- Interactive Viewer: Google Earth Engine App
- In-Depth Review: Earth Blox Dataset Review
- GRASS GIS Tutorial: Ecodiv.earth Tutorial
This script depends on specific versions of GDAL, the AWS CLI, and jq. The recommended and safest way to install these is by using a dedicated Conda environment. This prevents any conflicts with your existing system-level installations.
Install Conda: If you don't have it, install Miniconda or Micromamba (recommended for faster performance).
-
Clone the Repository:
git clone https://github.com/Jack-Hayes/fetch_meta_chm.git cd fetch_meta_chm -
Create and Activate the Environment: Use the
environment.ymlfile provided in this repository.-
Using Conda:
conda env create -f environment.yml conda activate fetch-chm-env
-
Using Micromamba:
micromamba create -f environment.yml micromamba activate fetch-chm-env
-
-
Make the Script Executable:
chmod +x fetch_meta_chm
The script can be run by providing an Area of Interest (AOI) as either a file or a bounding box. It supports GeoJSON files with single or multiple features.
Usage: ./fetch_meta_chm [-i <input_file>] [-b "<xmin ymin xmax ymax>"] [-c <icrs>] [-r <ocrs>] -o <output_dir>
Description:
Fetches Meta's 8-bit integer canopy height data for a given Area of Interest (AOI).
Creates a clipped Canopy Height Map (CHM) and a binary forest mask (pixels > 0).
If a GeoJSON with multiple features is provided, it processes each one.
Arguments:
Provide EITHER -i OR -b:
-i <input_file> Path to an input vector or raster file (e.g., .geojson, .shp, .tif).
-b "<bbox>" A bounding box string "xmin ymin xmax ymax". Requires -c.
Required:
-o <output_dir> Directory to save the output files.
Optional:
-c <icrs> Input CRS (e.g., 'EPSG:4326'). Required if using -b.
-r <ocrs> Output CRS. If provided, final rasters will be reprojected.1. From a GeoJSON file (CRS is auto-detected):
./fetch_meta_chm -i path/to/my_aoi.geojson -o ./output2. From a GeoTIFF file (CRS is auto-detected):
./fetch_meta_chm -i path/to/my_raster.tif -o ./output3. From a Bounding Box in WGS84 (EPSG:4326):
./fetch_meta_chm -b "113.722 -1.547 114.023 -1.271" -c EPSG:4326 -o ./output4. Reprojecting the Output to a different CRS (e.g., UTM):
./fetch_meta_chm -i my_aoi.geojson -o ./output -r EPSG:32632The script generates two GeoTIFF files for each AOI, named dynamically based on the output CRS and bounding box.
./output/
├── forest_mask_epsg-3857_948443_6019558_951781_6017862.tif
└── meta_chm_epsg-3857_948443_6019558_951781_6017862.tif- Runtime: For small areas (e.g., ~20 sq km), the workflow typically completes in under 2 minutes. Performance also depends on the number of source tiles the AOI intersects.
- File Size: The output files are small due to the 8-bit integer format, making them easy to share and manage.