Overview
This gfcanalysis
R package facilitates simple analyses using the Hansen et
al. 20131 Global Forest Change
dataset.
The package was written to analyze forest change in within the Zone of
Interaction surrounding each of the forest monitoring sites of the Tropical
Ecology Assessment and Monitoring (TEAM) Network.
If you need help with any of the functions in the package, see the help files
for more information. For example, type ?download_tiles
in R to see the help
file for the download_tiles
function.
Getting started
This post will outline an analysis using the gfcanalysis
package. Note that
as the computations are intensive, some parts of this analysis may take some
time to run (about 30 minutes total to run all of the code outlined here). If
you do not already have the GFC product data downloaded on your computer,
downloading the dataset will also take some time (though this process is
automated by gfcanalysis
).
To get started, first install the gfcanalysis
package from CRAN. Also install
the rgdal
package needed for reading/writing shapefiles if you do not already
have it.
Indicate where we want to save GFC tiles downloaded from Google. For any given AOI, the script will first check to see if these tiles are available locally (in the below folder) before downloading them from the server - so I recommend storing ALL of your GFC tiles in the same folder. For this example we will use “.” - the current working directory of the R session.
Set the threshold for forest/non-forest based on the treecover2000 layer in the GFC product:
Downloading data from Google server for a given AOI
Load an area of interest. For this example we use a shapefile of the Zone of Interaction (ZOI) of the TEAM Network site in Nam Kading National Protected Area, Laos. Notice that first we specify the folder the shapefile is in (here it is a “.” indicating the current working directory), and then the name of the shapefile without the “.shp”. To follow along with this example, download this shapefile of the ZOI.
Calculate the tiles needed to cover the AOI:
To check the overlap between the tiles and the aoi, you can make a plot of the needed tiles and the AOI using R’s plotting functions:
Now, check to see if these tiles are already present locally, and download them
if they are not. By default the “first” and “last” composite surface
reflectance images are not downloaded. To also download these images specify
first_and_last=TRUE
.
Performing thresholding and calculating basic statistics
Extract the GFC data for this AOI from the downloaded GFC tiles, mosaicing multiple tiles as necessary (if needed to cover the AOI). Save this extract in GeoTiff format in the current working directory (can also save as ENVI format, Erdas format, etc.)
The extracted dataset has 5 layers (not yet thresholded):
Threshold the GFC data based on a specified percent cover threshold (0-100), and save the thresholded layers to a GeoTiff:
Coding of the thresholded output
The thresholded dataset has 5 layers:
The output is coded using the following coding scheme:
Band 1 (forest2000)
Based on the provided forest_threshold
. Pixels wiwth percent canopy cover
greater than forest_threshold
are coded as forest.
Cover in 2000 | Code |
---|---|
Non-forest | 0 |
Forest | 1 |
Band 2 (lossyear)
Note that lossyear is zero for pixels that were not forested in 2000.
Year of loss | Code |
---|---|
No loss | 0 |
Loss in 2001 | 1 |
Loss in 2002 | 2 |
Loss in 2003 | 3 |
Loss in 2004 | 4 |
Loss in 2005 | 5 |
Loss in 2006 | 6 |
Loss in 2007 | 7 |
Loss in 2008 | 8 |
Loss in 2009 | 9 |
Loss in 2010 | 10 |
Loss in 2011 | 11 |
Loss in 2012 | 12 |
Band 3 (gain)
Note that gain is zero for pixels that were forested in 2000.
Change | Code |
---|---|
No gain | 0 |
Gain | 1 |
Band 4 (lossgain)
Note that loss and gain is difficult to interpret from the thresholded
product, as the original GFC product does not provide information on the
sequence of loss and gain (loss then gain, or gain then loss). The product also
does not provide information on the levels of canopy cover reached prior to
loss (for gain then loss) or after loss (for loss then gain pixels). The layer
is calculated here as: lossgain <- gain & (lossyear != 0)
, where lossyear
and gain
are the original GFC gain and lossyear layers, respectively.
Change | Code |
---|---|
No loss and gain | 0 |
Loss and gain | 1 |
Band 5 (datamask)
Class | Code |
---|---|
No data | 0 |
Land | 1 |
Water | 2 |
Calculating statistics on forest loss and forest gain
Calculate annual statistics on forest loss/gain:
Save these statistics to CSV files for use in Excel, or other software:
To view the output format of the CSV files output by gfcanalysis
, see the
loss
table
and gain
table
for Nam Kading.
Making simple visualizations
There is also a function in gfcanalysis
to calculate and save a thresholded
annual layer stack from the GFC product (useful for simple visualizations,
etc.):
The annual stack output by annual_stack
has one layer for each year:
Forest change in each year is coded as:
Cover/Change | Code |
---|---|
No data | 0 |
Forest | 1 |
Non-forest | 2 |
Forest loss | 3 |
Forest gain | 4 |
Forest loss and gain | 5 |
Water | 6 |
The animate_annual
function can be used to save a simple visualization of the
thresholded annual layer stack.
Note: For this example, we are using the data in the WGS84 coordinate system.
For a real analysis or presentation, the data should be projected into UTM or
another projection system for this. The utm_zone
function in the
gfcanalysis
package and the projectRaster
function in the raster
package
could be used to automate this. Also see the to_utm
option for the
extract_gfc
function (type ?extract_gfc
in R).
To make an annual animation (in WGS84) type:
The animation will be saved in the directory specified by out_dir
(in this
example the current working directory). To view the animation, double-click the
new “.html” file in that directory. The animation will look something like
this.
-
Hansen, M. C., P. V. Potapov, R. Moore, M. Hancher, S. A. Turubanova, A. Tyukavina, D. Thau, S. V. Stehman, S. J. Goetz, T. R. Loveland, A. Kommareddy, A. Egorov, L. Chini, C. O. Justice, and J. R. G. Townshend. 2013. High-Resolution Global Maps of 21st-Century Forest Cover Change. Science 342, (15 November): 850–853. Data available on-line from: http://earthenginepartners.appspot.com/science-2013-global-forest. ↩