Learn R Programming

GSIF (version 0.3-1)

spfkm: Supervised fuzzy k-means on spatial pixels

Description

Runs supervised fuzzy k-means (http://dx.doi.org/10.1080/13658810310001620924{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.

Usage

## S3 method for class 'formula,SpatialPointsDataFrame,SpatialPixelsDataFrame':
spfkm(formulaString,
           observations, covariates, class.c = NULL, class.sd = NULL, fuzzy.e = 1.2)

Arguments

formulaString
formula string
observations
object of type "SpatialPointsData"; occurrences of factors
covariates
object of type "SpatialPixelsData" or "RasterBrick"; list of covariate layers
class.c
object of type "matrix"; class centres (see examples below)
class.sd
object of type "matrix"; class deviations (see examples below)
fuzzy.e
object of type "numeric"; fuzzy exponent

Value

  • 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).

References

  • Burrough, P. A., Gaans, P.F.M., and Van Hootsmans, R., (1997)http://dx.doi.org/10.1016/S0016-7061(97)00018-9{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)http://dx.doi.org/10.1080/13658810310001620924{A double continuous approach to visualisation and analysis of categorical maps}. Int. Jou. of Geographical Information Science, 18(2): 183-202.

See Also

spmultinom, SpatialMemberships-class, nnet::multinom

Examples

Run this code
# load data:
library(plotKML)

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)
# 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