SC_AMKM {SCDA} | R Documentation |
Spatial Clustering for sf data
Description
Perform spatial clustering using K-means and AMKM (Adjacent Matrix K-Means) algorithms on sf data.
Usage
SC_AMKM(
Data_sf,
IndexCol,
Method,
Distance = "euclidean",
MinNc = 2,
MaxNc = 10,
Metric = "silhouette",
RidDim = "pca",
CenterVars = T,
ScaleVars = T,
MakePlot = T,
ExplainedVariance = 0.9,
KeepCoord = T,
Seed = 123456789,
Verbose = T,
CRS = 4326
)
Arguments
Data_sf |
A |
IndexCol |
|
Method |
|
Distance |
|
MinNc |
|
MaxNc |
|
Metric |
|
RidDim |
|
CenterVars |
|
ScaleVars |
|
MakePlot |
|
ExplainedVariance |
|
KeepCoord |
|
Seed |
|
Verbose |
|
CRS |
|
Details
AMKM calculations is done decomposing the input dataset in two subset. The first one contains the features while the second one contains the coordinates (longitude and latitude). A dissimilarity matrix is calculated on both subset using the parameter distance for the feature and the Great Circle distance for coordinates. Then an adjacent matrix (n x n) is computed on every dissimilarity matrix using gaussian kernel. To reduce the dimensionality of the adjacent matrix a dimentionality reduction method is necessary (see RidDim param. for more) K-means is applied with no modification at its original algorithm.
Value
A list object containing the following outputs:
df: n row dataframe with the following columns : ID, Longitude, Latitude and Cluster (the optimal partition)
plot: Display cluster partition in a map.
Author(s)
Camilla Lionetti <lionetticamilla511@gmail.com>, Francesco Caccia <francesco.caccia2000@gmail.com>
Examples
library(sp)
library(sf)
data("meuse")
dati<-meuse
dati<-subset(dati,select=sapply(dati,is.numeric))
dati<-st_as_sf(dati, coords = c("x", "y"),crs =28992)
SC <- SC_AMKM(Data_sf=dati,IndexCol=0, Method="AMKM",MinNc = 5,MaxNc = 5 ,CRS=28992)