Skip to contents

Calculation of the CO2 emissions resulting from forest loss in a time series. It uses information on the occurence of forest loss and the amount of CO2 present in the biomass to calculate the sum of CO2 emissions on a yearly basis.

Usage

CO2Calc(
  inputForestMap = NULL,
  inputLossMap = NULL,
  inputCO2Map = NULL,
  studysite = NULL,
  ncores = 1,
  polyName = NULL,
  saveCSV = FALSE,
  years = 2001:2018
)

Arguments

inputForestMap

A RasterLayer object with forest cover represented in binary (e.g 0 represents no forest; 1 represents forest). Each layer is expected to represent one year in the years object in a consecutive order.

inputLossMap

A RasterLayer object with values indicating the year tree cover was lost. The annual area of tree cover lost is calculated based on the values found in this data set.

inputCO2Map

A RasterLayer object with values indicating the the amount of CO2 equivalent present in the biomass of a given pixel. The annual sum of CO2 emissions per feature in the studysite object is calculated based on this data set.

studysite

An object of type sf with a given number of polygons defining the areas of interest. Forest area statistics will be calculated for features in the studysite object.

ncores

The number of cores to use, i.e. at most how many child processes will be run simultaneously.

polyName

charachter of length 1. Indicates the column in the data frame of the studysite object to uniquely identify the features of interest. The function will fail if there is no unique identification of the polygons

saveCSV

Default is FALSE. You can specify a directory on your local machine where the results area saved in .csv format. The features will be identified by the column specified in polyName.

years

A vector of type numeric indicating the years which are represented by pixels. For GFW data and the default these are 2001 to 2018.

Value

The studysite object with it's attribute table being ammended by the results of the calculation. Additionally, a csv file containing the polyName attribute as well as the results of the calculation can be saved to disk.

Note

This function relies heavily on parallization, indicating the importance of both, a high number of CPUs and large enough RAM.

Author

Darius Görgen (MapTailor Geospatial Consulting GbR) info@maptailor.net
Maintainer: MAPME-Initiative contact@mapme-initiative.org
Contact Person: Dr. Johannes Schielein
Copyright: MAPME-Initiative
License: GPL-3

Examples

library(sf)
library(raster)
library(mapme.forest)

aoi = st_read(system.file("extdata", "aoi_polys.gpkg", package = "mapme.forest"))
#> Reading layer `aoi_polys' from data source 
#>   `/home/runner/work/_temp/Library/mapme.forest/extdata/aoi_polys.gpkg' 
#>   using driver `GPKG'
#> Simple feature collection with 8 features and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 107.1291 ymin: 16.59741 xmax: 107.2502 ymax: 16.6916
#> Geodetic CRS:  WGS 84
yearlyRaster = stack(system.file("extdata", "pkgTest_yearlyCover.tif",
                                 package = "mapme.forest"))
lossRaster = raster(system.file("extdata", "pkgTest_lossyear.tif",
                                package = "mapme.forest"))
co2Raster = raster(system.file("extdata", "pkgTest_co2_emission.tif",
                               package = "mapme.forest"))

result = CO2Calc(inputForestMap = yearlyRaster,
                 inputLossMap = lossRaster,
                 inputCO2Map = co2Raster,
                 studysite = aoi[1,],
                 polyName = "id",
                 ncores = 1,
                 saveCSV = FALSE,
                 years = 2000:2018)
#> Warning: IMPORTANT WARNING: The use of the CO2 emission layer during analysis is currently discouraged.
#>            Several routines need to be adapted since the usage of a new data set by Harris et al (2021) (see https://www.nature.com/articles/s41558-020-00976-6)
#>            Check out https://github.com/mapme-initiative/mapme.forest/issues/7 to recieve information if the issue has been solved.
str(result)
#> Classes ‘sf’ and 'data.frame':	1 obs. of  21 variables:
#>  $ id      : int 1
#>  $ co2_2000: num 0
#>  $ co2_2001: num 0
#>  $ co2_2002: num 0
#>  $ co2_2003: num 0
#>  $ co2_2004: num 0
#>  $ co2_2005: num 33
#>  $ co2_2006: num 9450
#>  $ co2_2007: num 14526
#>  $ co2_2008: num 0
#>  $ co2_2009: num 253
#>  $ co2_2010: num 7.26
#>  $ co2_2011: num 0
#>  $ co2_2012: num 0
#>  $ co2_2013: num 2202
#>  $ co2_2014: num 1088
#>  $ co2_2015: num 368
#>  $ co2_2016: num 42.6
#>  $ co2_2017: num 27
#>  $ co2_2018: num 0
#>  $ geom    :sfc_POLYGON of length 1; first list element: List of 1
#>   ..$ : num [1:5, 1:2] 107 107 107 107 107 ...
#>   ..- attr(*, "class")= chr [1:3] "XY" "POLYGON" "sfg"
#>  - attr(*, "sf_column")= chr "geom"
#>  - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
#>   ..- attr(*, "names")= chr [1:20] "id" "co2_2000" "co2_2001" "co2_2002" ...