
Runs supervised fuzzy k-means (Hengl et al., 2004) using a list of covariates layers provided as "SpatialPixelsDataFrame-class"
object. If class centres and variances are not provided, it first fits a multinomial logistic regression model (spmultinom
), then predicts the class centres and variances based on the output from the nnet::multinom
.
# S4 method for formula,SpatialPointsDataFrame,SpatialPixelsDataFrame
spfkm(formulaString,
observations, covariates, class.c = NULL, class.sd = NULL, fuzzy.e = 1.2)
formula string
object of type "SpatialPointsData"
; occurrences of factors
object of type "SpatialPixelsData"
or "RasterBrick"
; list of covariate layers
object of type "matrix"
; class centres (see examples below)
object of type "matrix"
; class deviations (see examples below)
object of type "numeric"
; fuzzy exponent
Returns an object of type "SpatialMemberships"
with following slots: predicted
(classes predicted either by the multinomial logistic regression or fuzzy k-means), model
(the multinomial logistic regression model; if available), mu
(memberships derived using the fuzzy k-means), class.c
(submitted or derived class centres), class.sd
(submitted or derived class deviations), confusion
(confusion matrix).
Burrough, P. A., Gaans, P.F.M., and Van Hootsmans, R., (1997) Continuous classification in soil survey: spatial correlation, confusion and boundaries. Geoderma, 77(2-4), 115--135.
Hengl T., Walvoort D.J.J., Brown, A., (2004) A double continuous approach to visualisation and analysis of categorical maps. Int. Jou. of Geographical Information Science, 18(2): 183-202.
spmultinom
, SpatialMemberships-class
, nnet::multinom
# NOT RUN {
# load data:
library(plotKML)
library(sp)
data(eberg)
# subset to 20%:
eberg <- eberg[runif(nrow(eberg))<.2,]
data(eberg_grid)
coordinates(eberg) <- ~X+Y
proj4string(eberg) <- CRS("+init=epsg:31467")
gridded(eberg_grid) <- ~x+y
proj4string(eberg_grid) <- CRS("+init=epsg:31467")
# derive soil predictive components:
eberg_spc <- spc(eberg_grid, ~PRMGEO6+DEMSRT6+TWISRT6+TIRAST6)
# predict memberships:
formulaString = soiltype ~ PC1+PC2+PC3+PC4+PC5+PC6+PC7+PC8+PC9+PC10
eberg_sm <- spfkm(formulaString, eberg, eberg_spc@predicted)
# }
# NOT RUN {
# plot memberships:
pal = seq(0, 1, 1/50)
spplot(eberg_sm@mu, col.regions=grey(rev(pal)))
# predict soil properties using memberships:
glm.formulaString = as.formula(paste("SNDMHT_A ~ ",
paste(names(eberg_sm@mu), collapse="+"), "-1"))
SNDMHT.m2 <- fit.gstatModel(observations=eberg, glm.formulaString,
covariates=eberg_sm@mu)
summary(SNDMHT.m2@regModel)
# Coefficients correspond to the class centres;
# }
Run the code above in your browser using DataLab