spatialKMeans.Rd
In other words: 1) get k spatially representative points by performing k-means on a 2D matrix of lng lat 2) for each of these centroids, aggregate some function (e.g. median) of the covariates var over the numClosestPoints closest points spatially to get an idea of the value of var in a neighbourhood
spatialKMeans(
shp,
var,
numCentroids = NULL,
propToKeep = NULL,
numClosestPoints = 10,
aggFct = function(x) {
median(x, na.rm = T)
},
iter.max = 10^3
)
- string - variable to summarise
number of representative points to take (use EITHER numCentroids or numClosestPoints)
- analogous to bandwidth - larger number reduces the variance (use EITHER numCentroids or numClosestPoints)
- function to use to summarise - e.g. median or mean
max number of iterations for kmeans
shpCentroids with column var