exrct_Traindat_LLOCV: Extract training data from RasterStacks for LLOCV

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/exrct_Traindat_LLOCV.R

Description

Extracts values from a RasterStack of predictor variables by training polygons

Usage

1
2
3
4
5
6
7
exrct_Traindat_LLOCV(
  trainPoly,
  predStk,
  classCol = NULL,
  locname = NULL,
  lyrname = names(predStk)
)

Arguments

trainPoly

SpatialPolygonsDataframe - with training polygons to assign values

predStk

RasterStack - with layers to extract values from

classCol

character - name of the column containing the class information, default=NULL

locname

character - name of the column containing the location information, default=NULL

Details

This function is used to extract training data from a Raster Stack. This training dataset is used for IKARUS::BestPredFFS and IKARUS::RFclass.

Value

Returns a data.frame with values of each Rasterlayer per pixel for the training polygons along with the location. Additionally adds a column of the respective class information.

Note

the function will check for INF and or NA values. INF values are first set to NA and further all NA will be deleted to prevent errors in further processing with IKARUS::BestPredFFS and IKARUS::RFclass.

Author(s)

Andreas Schönberg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# load data
require(raster)
require(IKARUS)
lau_Stk <- raster::stack(system.file("extdata","lau_RGB.grd",package = "IKARUS"))
lau_tP <-rgdal::readOGR(system.file("extdata","lau_TrainPolygon.shp",package = "IKARUS"))
# handle CRS string
crs(lau_tP) <- crs(lau_Stk)
### check column names
names(lau_tP)
# -> lau_tP has both character and numeric class information
### extract values using character class information
tDat <- exrct_Traindat_LLOCV(lau_tP,lau_Stk,"class","location")
head(tDat)
### extract values using numeric class information
tDat2 <- exrct_Traindat_LLOCV(lau_tP,lau_Stk,"class_num","loc_num")
head(tDat2)

SchoenbergA/IKARUS documentation built on Sept. 8, 2021, 11:11 a.m.