Description Usage Arguments Details Value Note Author(s) Examples
View source: R/exrct_Traindat_LLOCV.R
Extracts values from a RasterStack of predictor variables by training polygons
1 2 3 4 5 6 7 | exrct_Traindat_LLOCV(
trainPoly,
predStk,
classCol = NULL,
locname = NULL,
lyrname = names(predStk)
)
|
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 |
This function is used to extract training data from a Raster Stack. This training dataset is used for IKARUS::BestPredFFS and IKARUS::RFclass.
classCol - the column with information about the class of a polygon. Supports either character or numeric values for classes (eg 1,2,3 or "tree","stone","grass")
predictor selection - specific predictors can be selected by using [[]] in parameter 'predStk'. E.g. predStk = x[1:4].
locname - the column with information about the location of the polygon for LLOCV. Supports either character or numeric values for classes (eg 1,2,3 or "north","east","west")
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.
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.
Andreas Schönberg
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.