Skip to content

Jack-Hayes/fetch_meta_chm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

fetch_meta_chm

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.


About the Dataset

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:


Prerequisites

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).

Installation

  1. Clone the Repository:

    git clone https://github.com/Jack-Hayes/fetch_meta_chm.git
    cd fetch_meta_chm
  2. Create and Activate the Environment: Use the environment.yml file 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
  3. Make the Script Executable:

    chmod +x fetch_meta_chm

Usage

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.

Examples

1. From a GeoJSON file (CRS is auto-detected):

./fetch_meta_chm -i path/to/my_aoi.geojson -o ./output

2. From a GeoTIFF file (CRS is auto-detected):

./fetch_meta_chm -i path/to/my_raster.tif -o ./output

3. From a Bounding Box in WGS84 (EPSG:4326):

./fetch_meta_chm -b "113.722 -1.547 114.023 -1.271" -c EPSG:4326 -o ./output

4. Reprojecting the Output to a different CRS (e.g., UTM):

./fetch_meta_chm -i my_aoi.geojson -o ./output -r EPSG:32632

Example Output

The 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

Performance

  • 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.

About

Local linux shell script to fetch Meta's 1m Global Canopy Height Model data and create a forest mask. Cloud-optimized workflow with GDAL/OGR (3.10) and the AWS CLI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages