Description Usage Arguments Details Examples
Generate a cost-based distance matrix among observations and/or between observations and prediction locations.
1 2 | distmatGen(pts, condsurf, ret = c("both", "obs", "loc"), directions = 16,
silent = FALSE)
|
pts |
A SpatialPoints[DataFrame] with a defined projection or a two-column data.frame/matrix of coordinates |
condsurf |
raster. Conductivity surface. |
ret |
specify whether to return distances between obs-obs ("obs"), obs-loc ("loc"), or both ("both") (default) |
directions |
See |
silent |
logical. If TRUE avoids any warnings or messages. |
Use the centroids of the conductivity or conductivity surface raster cells as prediction locations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | data(noise)
if (require(raster)) {
r <- raster(extent(c(0,3,0,3)), nrows = 3, ncols = 3)
wall.idx <- 4:5
values(r)[-wall.idx] <- 1
obs <- coordinates(r)[-wall.idx, ]
ddm <- distmatGen(obs, r, ret = "obs", directions = 8)
par(mfrow = c(2, 1))
plot(r)
text(obs[, 1], obs[, 2],
col = c('red', rep('black', 6)))
plot(dist(obs)[1:6], ddm[-1, 1],
type = 'n',
main = 'Distances to point 1',
xlab = 'Euclidean distance',
ylab = 'Cost-based distance')
text(dist(obs)[1:6], ddm[-1, 1],
labels = 2:7)
abline(0, 1)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.