View source: R/spatialKMeans.R
spatialKMeans | R Documentation |
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
)
var |
- string - variable to summarise |
numCentroids |
number of representative points to take (use EITHER numCentroids or numClosestPoints) |
numClosestPoints |
- analogous to bandwidth - larger number reduces the variance (use EITHER numCentroids or numClosestPoints) |
aggFct |
- function to use to summarise - e.g. median or mean |
iter.max |
max number of iterations for kmeans |
shpCentroids with column var
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.