7  Data from Global Forest Change

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 $GISDATA
mkdir -p $GISDATA/forest/global/GFC/

export SRC="https://storage.googleapis.com/earthenginepartners-hansen"

for VRS in GFC2015 GFC-2024-v1.12
do
    for VAR in gain lossyear treecover2000
    do
      mkdir -p $GISDATA/forest/global/GFC/$VRS/$VAR
      cd $GISDATA/forest/global/GFC/$VRS/$VAR
        wget $SRC/$VRS/$VAR.txt
      wget -b --continue -i $VAR.txt
    done
done

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:

source .env-local
tail $GISDATA/forest/global/GFC/GFC-2024-v1.12/treecover2000/wget-log.1
 12850K .......... .......... .......... .......... .......... 99% 6.62M 0s
 12900K .......... .......... .......... .......... .......... 99% 5.38M 0s
 12950K .......... .......... .......... .......... .......... 99% 7.65M 0s
 13000K ........                                              100%  133M=2.7s

2025-08-23 11:54:25 (4.65 MB/s) - ‘Hansen_GFC-2024-v1.12_treecover2000_80N_180W.tif’ saved [13320378/13320378]

FINISHED --2025-08-23 11:54:25--
Total wall clock time: 3h 4m 1s
Downloaded: 504 files, 55G in 3h 0m 36s (5.18 MB/s)

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.12
do
  for VAR in gain lossyear treecover2000
  do
    gdalbuildvrt index_${VRS}_${VAR}.vrt $GISDATA/forest/global/GFC/${VRS}/${VAR}/Hansen_${VRS}_${VAR}_*.tif
  done
done

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 $WORKDIR

for VRS in GFC2015 GFC-2024-v1.12
do
    mkdir -p $WORKDIR/$VRS
    for VAR in gain lossyear treecover2000 
    do
        OUTPUT=$WORKDIR/$VRS/${VRS}.M563.${VAR}.tif
        if [ -f $OUTPUT ]
        then 
            echo "$OUTPUT listo"
        else 
            gdalwarp -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 $OUTPUT
        fi
    done
done

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.

VRS=GFC-2024-v1.12
gdal_calc -A $WORKDIR/$VRS/${VRS}.M563.treecover2000.tif \
  -B $WORKDIR/$VRS/${VRS}.M563.lossyear.tif \
  -C $WORKDIR/$VRS/${VRS}.M563.gain.tif \
  --outfile=$WORKDIR/$VRS/${VRS}.M563.treecover2024.tif --calc="(A*(1-(B>0))) + (C*100)" 

7.4 That’s it!

Check output files:

ls -lah $WORKDIR/GFC-2024-v1.12
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.