Description Usage Arguments Details Value See Also Examples
Estimate location suitability with predictive models.
1 2 3 4 5 6 7 | ## S3 method for class 'PredictiveModelList'
predict(object, newdata, data.frame = FALSE,
...)
## S4 method for signature 'PredictiveModelList'
predict(object, newdata, data.frame = FALSE,
...)
|
object |
a PredictiveModelList object |
newdata |
data.frame containing new data |
data.frame |
logical indicating whether the function should return a matrix (default) or data.frame |
... |
additional arguments to |
This function is usually called from allocate
to calculate land use
suitability at each timestep. However, it may also be used to produce
suitability maps (see examples).
A matrix.
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 30 31 32 33 34 35 36 37 38 39 40 | ## Not run:
## Sibuyan Island
## load observed land use data
obs <- ObsLulcRasterStack(x=sibuyan$maps,
pattern="lu",
categories=c(1,2,3,4,5),
labels=c("Forest","Coconut","Grass","Rice","Other"),
t=c(0,14))
## load explanatory variables
ef <- ExpVarRasterList(x=sibuyan$maps, pattern="ef")
## separate data into training and testing partitions
part <- partition(x=obs[[1]], size=0.1, spatial=TRUE)
train.data <- getPredictiveModelInputData(obs=obs, ef=ef, cells=part[["train"]])
all.data <- getPredictiveModelInputData(obs=obs, ef=ef, cells=part[["all"]])
## get glm.models from data
forms <- list(Forest ~ ef_001+ef_002+ef_003+ef_004+ef_005+ef_006+ef_007+ef_008+ef_010+ef_012,
Coconut ~ ef_001+ef_002+ef_005+ef_007+ef_008+ef_009+ef_010+ef_011+ef_012,
Grass~ef_001+ef_002+ef_004+ef_005+ef_007+ef_008+ef_009+ef_010+ef_011+ef_012+ef_013,
Rice~ef_009+ef_010+ef_011,
Other~1)
glm.models <- glmModels(formula=forms, family=binomial, data=train.data, obs=obs)
## create suitability maps
suitability.maps <- predict(object=glm.models, newdata=all.data, data.frame=TRUE)
points <- rasterToPoints(obs[[1]], spatial=TRUE)
suitability.maps <- SpatialPointsDataFrame(coords=points, data=suitability.maps)
r <- stack(rasterize(x=suitability.maps, y=obs[[1]], field=names(suitability.maps)))
plot(r)
## library(rasterVis)
## levelplot(r)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.