Skip to contents

Calculation of the area where forest loss occured in a tree cover time series. It uses information on the occurence of forest loss and a forest mask to focus the analysis to pixles where lost occured. The area is then summed up for every polygon specified in the studysite object.

Usage

LossCalc(
  inputForestMap = NULL,
  inputLossMap = NULL,
  studysite = NULL,
  latlon = NULL,
  polyName = NULL,
  ncores = 1,
  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.

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.

latlon

logical: Indicates whether or not the inputForestMap object is based on a geographic coordinate system or is projected to a planar coordinate system. In the former case, area is approximated by raster::area.

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

ncores

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

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"))
lossYear = raster(system.file("extdata", "pkgTest_lossyear.tif",
                              package = "mapme.forest"))

result = LossCalc(inputForestMap = yearlyRaster,
                 inputLossMap = lossYear,
                 studysite = aoi[1,],
                 latlon = TRUE,
                 polyName = "id",
                 ncores = 1,
                 saveCSV = FALSE,
                 years = 2000:2018)
str(result)
#> Classes ‘sf’ and 'data.frame':	1 obs. of  21 variables:
#>  $ id       : int 1
#>  $ loss_2000: num 0.033
#>  $ loss_2001: num 0
#>  $ loss_2002: num 0
#>  $ loss_2003: num 0
#>  $ loss_2004: num 0
#>  $ loss_2005: num 0.000737
#>  $ loss_2006: num 0.23
#>  $ loss_2007: num 0.356
#>  $ loss_2008: num 0
#>  $ loss_2009: num 0.00637
#>  $ loss_2010: num 0.000206
#>  $ loss_2011: num 0
#>  $ loss_2012: num 0
#>  $ loss_2013: num 0.0598
#>  $ loss_2014: num 0.0314
#>  $ loss_2015: num 0.00959
#>  $ loss_2016: num 0.00109
#>  $ loss_2017: num 0.000737
#>  $ loss_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" "loss_2000" "loss_2001" "loss_2002" ...