vignettes/introduction.R

## ----setup, include = FALSE----------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ------------------------------------------------------------------------
library(rasterTools)

myDatasets <- list(list(operator = "oGFC", period = c(2006)),
                   list(operator = "oMODIS", product = "mod17a3", period = 2006,
                        layer = 2))

## ------------------------------------------------------------------------
myMask <- rtGeoms$mask

## ----eval=FALSE----------------------------------------------------------
#  myData <- obtain(data = myDatasets, mask = myMask)

## ------------------------------------------------------------------------
get_patches <- list(list(operator = "rBinarise", thresh = 30),
                    list(operator = "rPatches"))

## ------------------------------------------------------------------------
cc_cats <- list(get_patches = list(operator = "rBinarise", thresh = 30),
                get_patches = list(operator = "rPatches"),
                get_categories = list(operator = "rCategorise", n = 5))

## ---- fig.width=7, out.width='100%'--------------------------------------
myInput <- rtRasters$continuous
myPatches <- modify(input = myInput, by = get_patches, sequential = TRUE)
# visualise(raster::stack(myInput, myPatches))

## ------------------------------------------------------------------------
myInput <- rtRasters$categorical
myMetrics <- list(a_c = list(operator = "mArea", scale = "class"),
                  a_l = list(operator = "mArea", scale = "landscape"))
measure(input = myInput, with = myMetrics)

## ------------------------------------------------------------------------
myMetric <- list(a_c = list(operator = "mArea", scale = "class"),
                 a_l = list(operator = "mArea", scale = "landscape"),
                 mCPA = "a_c / a_l * 100")

## ------------------------------------------------------------------------
myMetrics <- list(a_p = list(operator = "mArea", scale = "patch"),
                  a_c = list(operator = "mArea", scale = "class"),
                  a_l = list(operator = "mArea", scale = "landscape"),
                  mCPA = "a_c / a_l * 100",
                  mLPI = "max(a_p) / a_l * 100")

## ------------------------------------------------------------------------
measure(input = myInput, with = myMetrics)
EhrmannS/rasterTools documentation built on Sept. 4, 2019, 10:34 a.m.