spfkm,formula,SpatialPointsDataFrame,SpatialPixelsDataFrame-method | R Documentation |
Runs supervised fuzzy k-means (Hengl et al., 2004; doi: 10.1080/13658810310001620924) 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 centers and variances based on the output from the nnet::multinom
.
## S4 method for signature ## 'formula,SpatialPointsDataFrame,SpatialPixelsDataFrame' spfkm( formulaString, observations, covariates, class.c = NULL, class.sd = NULL, fuzzy.e = 1.2 )
formulaString |
formula. |
observations |
SpatialPointsDataFrame. |
covariates |
SpatialPixelsDataFrame. |
class.c |
class centers (per variable). |
class.sd |
class standard deviation (per variable). |
fuzzy.e |
fuzzy coefficient. |
A fuzzy kmeans model
if(requireNamespace("plotKML")){ library(plotKML) library(sp) library(nnet) 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))) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.