knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
ddl8s1ts
is an R package for detecting and mapping forest disturbance using Landsat 8 and Sentinel-1 time seires. Harmonic regression models are applied to both Landsat 8 and Sentinel-1 time series to predict disturbance probability. Disturbance is detected based on the time series of disturbance probabilities predicted by Random Forests (RF).
You can install the latest version from GitHub using devtools
:
devtools::install_github("dulvrq/ddl8s1ts") library(ddl8s1ts)
Currently, mapDisturbanceL8S1()
is an only usable function in this package. All other functions are called by this function. Several data are required for running mapDisturbanceL8S1()
to detect and map disturbance. The followings are key variables that should be prepared beforehand.
suppressWarnings(library(raster, quietly = T)) library(ddl8s1ts) dir_main <- dirname(dirname(getwd())) # ls_l8 ls_s1 dir_l8 <- paste0(dir_main, "/GIS_data/_for_share/Landsat_SR") list_l8 <- list.files(dir_l8, "tif$", full.names = T) list_l8 <- gsub("OutPut_", "", list_l8) dir_s1 <- paste0(dir_main, "/GIS_data/_for_share/Sentinel-1_VV_VH") list_s1 <- list.files(dir_s1, "tif$", full.names = T) list_s1 <- gsub("OutPut_", "", list_s1)
Landsat 8 data
ls_l8
: requires a file list of 6 bands images of Landsat 8 (B2, B3, B4, B5, B6, and B7). All images must have the same extent (origin, resolution, and crs). These should be surface reflectance products, may be from Google Earth Engine (GEE) or other preprocessing chains. NoData values should be NA
, not 0 (sometimes occurred in GEE output). An exmaple of this product is the following.
# an example data in this package head(ls_l8, 1)
When you use your own data, it is also acceptable to use a filename provided by list.files
as follows.
# use list.files to list files in your directory head(basename(list_l8))
Sentinel-1 data
ls_s1
: requires a file list of 2 bands images of Sentinel-1 (VV and VH). All images must have the same extent (origin, resolution, and crs). These might be from GEE or other preprocessing chains. An exmaple of this product is the following.
# an example data in this package head(ls_s1, 1)
Of course you can use a filename provided by list.files
in the same manner.
# use list.files to list files in your directory head(basename(list_s1))
Julian day of Landsat 8 and Sentinel-1 data
l8_doys
: is a list of julian day of Landsat 8. This should be the same order and length as ls_l8
.
s1_doys
: is a list of julian day of Sentinel-1. This should be the same order and length as ls_s1
.
# calculate julian day from filenames fname_l8 <- sapply(ls_l8, function(x) names(x)[1]) fname_s1 <- sapply(ls_s1, function(x) names(x)[1]) n <- 18 l8_dates <- paste(substring(fname_l8, n, n+3), substring(fname_l8, n+4, n+5), substring(fname_l8, n+6, n+7), sep = "-") l8_doys <- as.numeric(substring(fname_l8, n, n+3)) + as.numeric(strftime(l8_dates, format = "%j")) / 365 s1_dates <- paste(substring(fname_s1, n, n+3), substring(fname_s1, n+4, n+5), substring(fname_s1, n+6, n+7), sep = "-") s1_doys <- as.numeric(substring(fname_s1, n, n+3)) + as.numeric(strftime(s1_dates, format = "%j")) / 365 head(l8_doys) head(s1_doys)
Reference data for disturbance detection
dt_ref
: is a dataframe of reference data for RF modeling. This should contain column x
, y
, and date
.
x
and y
should indicate locations of reference samples in the same crs as Landsat 8 or Sentinel-1.
date
should indicate the timing of disturbance. If there is no disturbance at the sample location, use NA
.
# an example data in this package head(dt_ref)
Others
ls_dem
: a filename of DEM with 2 bands (elevation and slope). Optional. If DEM will be not used for model, use NULL
.
dir_save
: a directory for save the results. NULL is acceptable.
VI
: a list of spectral index used for Landsat 8.
rf_model
: use NULL
to build RF model. To skip RF modeling, provide a list of two RF models.
startDOY
: a start date of disturbance detection.
endDOY
: a end date of disturbance detection.
mmu
: a minimum mapping unit (pixel) for final mapping. Use NULL
to avoid mmu
.
only_rf
: If TRUE
, only build RF models. If FALSE
, build RF models and map disturbance detection.
max_cores
: a maximum cores used for parallel processing.
threshold
: a threshold to detect disturbance from time series disturbance probabilities.
ls_dem <- NULL # do not use DEM in RF models dir_save <- getwd() startDOY <- 2016 # detect disturbance from 2016/01/01 endDOY <- 2018 # detect disturbance until 2017/12/31 mmu <- 4 VI <- c("NBR", "TCA8", "TCB8", "TCG8","TCW8") # NBR, TCA, TCB, TCG, and TCW max_cores <- 20 threshold <- 0.5
mapDisturbanceL8S1()
has 2 processing parts: RF model building and disturbance mapping. A simple implementation is to process both as follows. Please note that this function uses parallel processing and consume much memory and CPUs. Furthermore, this process takes very long time.
# use only_rf = F & rf_model = NULL to run entire process. mapDisturbanceL8S1(ls_l8, ls_s1, l8_doys, s1_doys, dt_ref, ls_dem, dir_save, VI, rf_model = NULL, startDOY, endDOY, mmu, only_rf = F, max_cores, threshold)
If you would like to use either of Landsat 8 or Sentinel-1, use NULL to either of file list.
# use ls_s1 = NULL. mapDisturbanceL8S1(ls_l8, NULL, l8_doys, NULL, dt_ref, ls_dem, dir_save, VI, rf_model = NULL, startDOY, endDOY, mmu, only_rf = F, max_cores, threshold)
If you would like to run only RF model building, such as in case that samples are from large extent but would like to map only small extent, then use only_rf = TRUE
. This only generate RF models in a subfolder.
# use only_rf = T. mapDisturbanceL8S1(ls_l8, ls_s1, l8_doys, s1_doys, dt_ref, ls_dem, dir_save, VI, rf_model = NULL, startDOY, endDOY, mmu, only_rf = T, max_cores, threshold)
If you would like to run only disturbance mapping, such as in case of mapping only small extent, then provide a list of two RF models (Landsat and Sentinel-1).
# provide rf_model, a list of two RF models. mapDisturbanceL8S1(ls_l8, ls_s1, l8_doys, s1_doys, dt_ref, ls_dem, dir_save, VI, rf_model = rf_model, startDOY, endDOY, mmu, only_rf = F, max_cores, threshold)
Shimizu, K. Ota, T. Mizoue, N. (2019) Detecting Forest Changes Using Dense Landsat 8 and Sentinel-1 Time Series Data in Tropical Seasonal Forests. Remote Sensing 11: 1899. doi.org/10.3390/rs11161899
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.