optimMSSD: Optimization of sample configurations for spatial...

Description Usage Arguments Details Value Note Author(s) References See Also Examples


Optimize a sample configuration for spatial interpolation. The criterion used is the mean squared shortest distance (MSSD) between sample points and prediction points.


optimMSSD(points, candi, schedule = scheduleSPSANN(), plotit = FALSE,
  track = FALSE, boundary, progress = "txt", verbose = FALSE)

objMSSD(points, candi)



Integer value, integer vector, data frame or matrix, or list.

  • Integer value. The number of points. These points will be randomly sampled from candi to form the starting sample configuration.

  • Integer vector. The row indexes of candi that correspond to the points that form the starting sample configuration. The length of the vector defines the number of points.

  • Data frame or matrix. An object with three columns in the following order: [, "id"], the row indexes of candi that correspond to each point, [, "x"], the projected x-coordinates, and [, "y"], the projected y-coordinates.

  • List. An object with two named sub-arguments: fixed, a data frame or matrix with the projected x- and y-coordinates of the existing sample configuration – kept fixed during the optimization –, and free, an integer value defining the number of points that should be added to the existing sample configuration – free to move during the optimization.


Data frame or matrix with the candidate locations for the jittered points. candi must have two columns in the following order: [, "x"], the projected x-coordinates, and [, "y"], the projected y-coordinates.


List with 11 named sub-arguments defining the control parameters of the cooling schedule. See scheduleSPSANN.


(Optional) Logical for plotting the optimization results, including a) the progress of the objective function, and b) the starting (gray circles) and current sample configuration (black dots), and the maximum jitter in the x- and y-coordinates. The plots are updated at each 10 jitters. When adding points to an existing sample configuration, fixed points are indicated using black crosses. Defaults to plotit = FALSE.


(Optional) Logical value. Should the evolution of the energy state be recorded and returned along with the result? If track = FALSE (the default), only the starting and ending energy states are returned along with the results.


(Optional) SpatialPolygon defining the boundary of the spatial domain. If missing and plotit = TRUE, boundary is estimated from candi.


(Optional) Type of progress bar that should be used, with options "txt", for a text progress bar in the R console, "tk", to put up a Tk progress bar widget, and NULL to omit the progress bar. A Tk progress bar widget is useful when using parallel processors. Defaults to progress = "txt".


(Optional) Logical for printing messages about the progress of the optimization. Defaults to verbose = FALSE.


Details about the mechanism used to generate a new sample configuration out of the current sample configuration by randomly perturbing the coordinates of a sample point are available in the help page of spJitter.

Spatial coverage sampling

Spatial coverage sampling is based on the knowledge that the kriging variance depends upon the distance between sample points. As such, the better the spread of the sample points in the spatial domain, the smaller the kriging variance. This is similar to using a regular grid of sample points. However, a regular grid usually is suboptimal for irregularly shaped areas.


optimMSSD returns an object of class OptimizedSampleConfiguration: the optimized sample configuration with details about the optimization.

objMSSD returns a numeric value: the energy state of the sample configuration – the objective function value.


The distance between two points is computed as the Euclidean distance between them. This computation assumes that the optimization is operating in the two-dimensional Euclidean space, i.e. the coordinates of the sample points and candidate locations should not be provided as latitude/longitude. spsann has no mechanism to check if the coordinates are projected: the user is responsible for making sure that this requirement is attained.

This function was derived with modifications from the method known as spatial coverage sampling originally proposed by Brus, de Gruijter and van Groenigen (2006), and implemented in the R-package spcosa by Dennis Walvoort, Dick Brus and Jaap de Gruijter.


Alessandro Samuel-Rosa alessandrosamuelrosa@gmail.com


Brus, D. J.; de Gruijter, J. J.; van Groenigen, J.-W. Designing spatial coverage samples using the k-means clustering algorithm. In: P. Lagacherie,A. M.; Voltz, M. (Eds.) Digital soil mapping – an introductory perspective. Elsevier, v. 31, p. 183-192, 2006.

de Gruijter, J. J.; Brus, D.; Bierkens, M.; Knotters, M. Sampling for natural resource monitoring. Berlin: Springer, p. 332, 2006.

Walvoort, D. J. J.; Brus, D. J.; de Gruijter, J. J. An R package for spatial coverage sampling and random sampling from compact geographical strata by k-means. Computers and Geosciences. v. 36, p. 1261-1267, 2010.

See Also

[distanceFromPoints](https://CRAN.R-project.org/package=raster), [stratify](https://CRAN.R-project.org/package=spcosa).


candi <- meuse.grid[, 1:2]
schedule <- scheduleSPSANN(chains = 1, initial.temperature = 5000000,
                           x.max = 1540, y.max = 2060, x.min = 0, 
                           y.min = 0, cellsize = 40)
res <- optimMSSD(points = 10, candi = candi, schedule = schedule)
objSPSANN(res) - objMSSD(candi = candi, points = res)

spsann documentation built on May 2, 2019, 1:36 p.m.