-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandbox_comparison.R
45 lines (29 loc) · 1.44 KB
/
sandbox_comparison.R
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
## Comparison of movecost, fastmarching and fasthiking functions
library(raster)
# movecost ----------------------------------------------------------------
library(movecost)
volc <- raster::raster(system.file("external/maungawhau.grd", package="gdistance"))
values(volc) <- 100
#volc[20,20:40] <- 1000
# data(volc.loc)
# data(destin.loc)
# res.mc <- movecost(dtm=volc, origin=volc.loc, destin=destin.loc, breaks=0.05)
#
# fasthiking ------------------------------------------------------------
#devtools::install_github('f-silva-archaeo/fastmaRching')
library(fastmaRching)
# Voronoi diagram demo ----------------------------------------------------
seeds <- destin.loc
seeds@data <- data.frame(Id=1:length(seeds), incept=rep(0,length(seeds)), off.path=rep(F,length(seeds)))
res.fh <- spFastHike(volc, seeds)
par(mfrow=c(1,2), mar=c(1,1,1,3))
plot(res.fh$arrival.time, axes=F); contour(res.fh$arrival.time, add=TRUE)
plot(res.fh$process, axes=F); contour(res.fh$arrival.time, add=TRUE)
# First Arrival demo ------------------------------------------------------
seeds <- destin.loc[c(4,8),]
seeds@data <- data.frame(Id=1:2, incept=rep(0,2), off.path=rep(F,2), v0=c(2,NA))
res.fh <- spFastHike(volc, seeds)
par(mfrow=c(1,2), mar=c(1,1,1,3))
plot(res.fh$arrival.time, axes=F); contour(res.fh$arrival.time, add=TRUE)
plot(res.fh$process, axes=F); contour(res.fh$arrival.time, add=TRUE)
ttt <- spSpath(res.fh$arrival.time, destin.loc[1]) ## TODO make this work