I have been trying to calculate forest cover and forest loss in West Kalimantan Province, Indonesia, during 2000-2020. I use the gfcanalysis package in R for this purpose. Unfortunately, the minimum value of the forest cover raster turned to be -20 (minus) after reprojecting it to UTM 49 S, whereas the original value should be 0 (zero).
Following http://azvoleff.com/articles/analyzing-forest-change-with-gfcanalysis/, here are my codes to generate the output:
library('sp')
library('raster')
library('rgdal')
library('gfcanalysis')
// set working directory
setwd("D:/Users/GFC")
getwd()
// prepare output folder
output_folder <- "C:/Users/GFC/forestloss"
// download boundary of West Papua Province (WPP) via GADM
idn <- getData('GADM', country='IDN', level=1, download = TRUE)
// inspect GADM and choose WPP
idn@data
idn <- idn[idn$NAME_1 == "Kalimantan Barat",]
// reproject GADM to UTM 49S
idn.utm <- spTransform(idn, CRS("+init=epsg:32749"))
plot(idn.utm)
// calculate tiles needed to cover WPP
tiles <- calc_gfc_tiles(idn)
print(length(tiles))
// download GFC for WPP
download_tiles(tiles, output_folder)
// extract GFC data for WPP
gfc_extract <- extract_gfc(idn, output_folder, to_UTM=F, filename="GFC_extract.tif")
// reproject GFC
gfc_extract_utm <- projectRaster(gfc_extract, crs = "+init=epsg:32749")
gfc_extract_utm
// set forest threshold: 30%
forest_threshold <- 30
// thresholded GFC
gfc_ extract_utm_th<- threshold_gfc(gfc_extract_utm, forest_threshold=forest_threshold, filename="gfc_ extract_utm_th.tif")
// calculate forest statistics
gfc_statistics <- gfc_stats(idn.utm, gfc_ extract_utm_th)
Any idea what is happening?