We use tree cover data from the High-Resolution Global Maps of 21st-Century Forest Cover Change project (Hansen et al. 2013). General information and download instructions for the latest version are available here.
We do these steps in a terminal emulator (shell) using some commonly available command line programs and the gdal library.
7.1 Data download
For all versions of the dataset we can use a simple shell script to download the whole set. For this analysis we downloaded v1.2 (2015) and v1.12 (2024):
source .env-local # This contains the value for the local folder $GISDATAmkdir-p$GISDATA/forest/global/GFC/exportSRC="https://storage.googleapis.com/earthenginepartners-hansen"for VRS in GFC2015 GFC-2024-v1.12dofor VAR in gain lossyear treecover2000domkdir-p$GISDATA/forest/global/GFC/$VRS/$VARcd$GISDATA/forest/global/GFC/$VRS/$VARwget$SRC/$VRS/$VAR.txtwget-b--continue-i$VAR.txtdonedone
We tested this script (and others below) using bash in a couple of Linux distros and bash and zsh in MacOS.
Downloading the complete dataset for each variable requires some time and storage:
After download, we can build a VRT file which is a virtual mosaic of the list of input files.
cd$GISDATA/forest/global/GFC/for VRS in GFC2015 GFC-2024-v1.12dofor VAR in gain lossyear treecover2000dogdalbuildvrt index_${VRS}_${VAR}.vrt $GISDATA/forest/global/GFC/${VRS}/${VAR}/Hansen_${VRS}_${VAR}_*.tifdonedone
7.2 Data preparation
Using gdalwarp from the gdal library, we can create a geotiff output file for the area of interest. Here we specify the area of interest using two parameter to speed up processing: first we define a window or bounding box (with coordinates passed to argument -te), and then use the vector boundary (file passed to argument -cutline) to extract the values within that boundary.
cd$WORKDIRfor VRS in GFC2015 GFC-2024-v1.12domkdir-p$WORKDIR/$VRSfor VAR in gain lossyear treecover2000 doOUTPUT=$WORKDIR/$VRS/${VRS}.M563.${VAR}.tifif[-f$OUTPUT]thenecho"$OUTPUT listo"elsegdalwarp-te-77.37 1.99 -60.42 12.46 -cutline 1.A.1.Ei.563---Guajiran-Seasonal-Dry-Forest-1km.gpkg -co"COMPRESS=LZW"$GISDATA/forest/global/GFC/index_${VRS}_${VAR}.vrt $OUTPUTfidonedone
7.3 Raster algebra
For the assessments we need to calculate the area remaining after considering loss and gains since 2000. This can be approximated using raster algebra by starting with the treecover for 2000, then substracting pixels with any loss (multiplying by zero whenever lossyear is greater than 0) and finally adding pixels with gain.
We use gdal_calc from the gdal libraries to complete this step in the terminal, which is faster than doing the equivalent within an R session.
total 6055400
drwxr-xr-x 6 z3529065 staff 192B 25 Aug 07:55 .
drwxr-xr-x 12 z3529065 staff 384B 23 Aug 13:34 ..
-rw-r--r-- 1 z3529065 staff 20M 23 Aug 13:52 GFC-2024-v1.12.M563.gain.tif
-rw-r--r-- 1 z3529065 staff 42M 23 Aug 13:53 GFC-2024-v1.12.M563.lossyear.tif
-rw-r--r-- 1 z3529065 staff 186M 23 Aug 13:54 GFC-2024-v1.12.M563.treecover2000.tif
-rw-r--r-- 1 z3529065 staff 2.6G 25 Aug 09:06 GFC-2024-v1.12.M563.treecover2024.tif
These files are now ready for our assessment.
Hansen, M. C., P. V. Potapov, R. Moore, M. Hancher, S. A. Turubanova, A. Tyukavina, D. Thau, et al. 2013. “High-Resolution Global Maps of 21st-Century Forest Cover Change.”Science 342 (6160): 850–53. https://doi.org/10.1126/science.1244693.