Skip to content

Commit

Permalink
simplify code - remove extraneous steps
Browse files Browse the repository at this point in the history
  • Loading branch information
geryan committed Dec 12, 2024
1 parent 07e30af commit 26384e3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/calculate_travel_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ calculate_travel_time <- function(
tsn <- gdistance::transition(friction, function(x) 1/mean(x), 8)
tgc <- gdistance::geoCorrection(tsn)

xy.data.frame <- data.frame()
xy.data.frame[1:npoints,1] <- points[,1]
xy.data.frame[1:npoints,2] <- points[,2]
xy.matrix <- as.matrix(xy.data.frame)
# xy.data.frame <- data.frame()
# xy.data.frame[1:npoints,1] <- points[,1]
# xy.data.frame[1:npoints,2] <- points[,2]
# xy.matrix <- as.matrix(xy.data.frame)

xy.matrix <- as.matrix(points[,1:2])

travel_time <- gdistance::accCost(tgc, xy.matrix)
names(travel_time) <- "travel_time"
Expand Down

0 comments on commit 26384e3

Please sign in to comment.