Description Usage Arguments Details Value Author(s) Examples
View source: R/spatialSpread.R
This is a wrapper function to compute cost of a set of sensors based on their coordinates only. It takes as parameter fun an actual function to compute such cost for each location of the provided simulations and can summarise it with a function fun_R
1 | spatialSpread(simulations, locations, weightByArea = TRUE, fun, fun_R)
|
simulations |
|
locations |
indices of |
weightByArea |
if cost in the locations has to be multiplied by the area associated to them before summary; for |
fun |
|
fun_R |
|
The function itself is only a wrapper to turn simulations and locations into the correct form and apply the functions.
List
cost |
result of |
costLocations |
result of |
Kristina B. Helle, kristina.helle@uni-muenster.de
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | # prepare data and functions
data(radioactivePlumes)
data(medianVariogram)
krigingVarianceMedian =
replaceDefault(krigingVariance, newDefaults = list(model = medianVariogram))[["fun"]]
meanFun = function(x){mean(x, na.rm = TRUE)}
locationsSensors = sample.int(nLocations(radioactivePlumes), 50)
spatialSpread_minDist = spatialSpread(
simulations = radioactivePlumes,
locations = locationsSensors,
weightByArea = TRUE,
fun = minimalDistance,
fun_R = meanFun
)
spatialSpread_krigingVar = spatialSpread(
simulations = radioactivePlumes,
locations = locationsSensors,
weightByArea = TRUE,
fun = krigingVarianceMedian,
fun_R = meanFun
)
# plot maps
## Not run:
## takes some seconds
y = radioactivePlumes@locations
y@data$minDist = spatialSpread_minDist[["costLocations"]]
y@data$krigVar = spatialSpread_krigingVar[["costLocations"]]
yPoints = as(y, "SpatialPointsDataFrame")
# distance to next sensor
spplot(y, zcol = "minDist",
sp.layout = list("sp.points", yPoints[locationsSensors,],
col = 3))
# kriging variance
spplot(y, zcol = "krigVar",
sp.layout = list("sp.points", yPoints[locationsSensors,],
col = 3))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.