# NOT RUN {
library(sp)
# creating a simple network
wkt_lines <- c(
"LINESTRING (0.0 0.0, 5.0 0.0)",
"LINESTRING (0.0 -5.0, 5.0 -5.0)",
"LINESTRING (5.0 0.0, 5.0 5.0)",
"LINESTRING (5.0 -5.0, 5.0 -10.0)",
"LINESTRING (5.0 0.0, 5.0 -5.0)",
"LINESTRING (5.0 0.0, 10.0 0.0)",
"LINESTRING (5.0 -5.0, 10.0 -5.0)",
"LINESTRING (10.0 0, 10.0 -5.0)",
"LINESTRING (10.0 -10.0, 10.0 -5.0)",
"LINESTRING (15.0 -5.0, 10.0 -5.0)",
"LINESTRING (10.0 0.0, 15.0 0.0)",
"LINESTRING (10.0 0.0, 10.0 5.0)")
linesdf <- data.frame(wkt = wkt_lines,
id = paste("l",1:length(wkt_lines),sep=""))
geoms <- do.call(rbind,lapply(1:nrow(linesdf),function(i){
txt <- as.character(linesdf[i,]$wkt)
geom <- rgeos::readWKT(txt,id=i)
return(geom)
}))
lines <- SpatialLinesDataFrame(geoms, linesdf, match.ID = FALSE)
# and the definition of the starting point
start_points <- data.frame(x=c(5),
y=c(-2.5))
coordinates(start_points) <- cbind(start_points$x,start_points$y)
# setting the directions
lines$direction <- "Both"
lines[6,"direction"] <- "TF"
isochrones <- calc_isochrones(lines, dists = c(10,12),
start_points = start_points,
direction = "direction")
# }
Run the code above in your browser using DataLab