classSegVal: Validate a Tree Prediction with TreeCrown Segments

Description Usage Arguments Value Author(s) Examples

View source: R/classSegVal.R

Description

calculates the amount of cells for class "trees" which overlap with TreeCrown Segments.

Usage

1
classSegVal(pred, seg, classTree = NULL, reclass = NULL)

Arguments

pred

RasterLayer - Prediction to be validated

seg

PolygonLayer - Segments with TreeCrowns

classTree

numeric - The class representing Trees

reclass

optional - numeric value of class to merge into class "trees", for multiple classes to merge use reclass=c(x,y)

Value

returns the validation score

Author(s)

Andreas Schönberg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# load data
require(caret)
require(CAST)
require(doParallel)
require(raster)
require(IKARUS)
require(mapview)
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)
# load segments
lau_seg <-rgdal::readOGR(system.file("extdata","lau_TreeSeg.shp",package = "IKARUS"))
# handle CRS string
crs(lau_seg) <- crs(lau_Stk)
### extract values using 'exrct_Tdat' to generate training dataset
tDat <- exrct_Traindat(lau_tP,lau_Stk,"class")
# check for class column and predictor columns in input training dataset
head(tDat)
# classification
model1 <- RFclass(tDat = tDat,predCol = "default",predStk = lau_Stk,classCol = "class")
#check model and seg
plot(model1$prediction)
plot(lau_seg)

# test several combinations of classes for tress
tree <- classSegVal(  pred=model1$prediction,  seg=lau_seg,  classTree=4,  reclass=NULL)
tnsha <- classSegVal(  pred=model1$prediction,  seg=lau_seg,  classTree=4,  reclass=2)
tnshangras <- classSegVal(  pred=model1$prediction,  seg=lau_seg,  classTree=4,  reclass=c(2,3))

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