# NOT RUN {
require(raster)
# read remote sensing data
file <- list.files(system.file('extdata', '', package="rsMove"), 'tc.*tif', full.names=TRUE)
rsStk <- stack(file)
# read movement data
moveData <- read.csv(system.file('extdata', 'konstanz_20130805-20130811.csv', package="rsMove"))
moveData <- SpatialPointsDataFrame(moveData[,1:2], moveData, proj4string=crs(rsStk))
# retrieve remote sensing data for samples
rsQuery <- dataQuery(xy=moveData,img=rsStk, remove.dup=TRUE)
# identify unique sample regions
label <- labelSample(xy=rsQuery, rad=90, npx=1, pxr=rsStk)
# select background samples
ind <- which(label>0) # selected samples
bSamples <- backSample(xy=moveData[ind,], rid=label[ind], img=rsStk, nb=4000, method='pca')
# derive model predictions
fun <- function(x,y) {train(x, y, method="rf", trControl=trainControl(method='oob'))}
p.model <- moveModel(p.data=rsQuery@data, a.data=bSamples@data, label=label, fun=fun, nruns=1)
# derive prediction from model ensemble
fun <- function(x,y) {predict(x, y, type='prob')[[1]]$`1`}
prob <- modelApply(p.model, rsStk, fun=fun)
# see output
plot(prob)
# }
Run the code above in your browser using DataLab