library(sf)
# 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=""))
lines <- st_as_sf(linesdf, wkt = "wkt", crs = 32188)
# and the definition of the starting point
start_points <- data.frame(x=c(5),
y=c(-2.5))
start_points <- st_as_sf(start_points, coords = c("x","y"), crs = 32188)
# setting the directions
lines$direction <- "Both"
lines[6,"direction"] <- "TF"
isochrones <- calc_isochrones(lines,dists = c(10,12),
donught = TRUE,
start_points = start_points,
direction = "direction")
Run the code above in your browser using DataLab