我经常需要设计最短的步行路线,使我在多边形中所有点的 100 米以内。我通常在地图上画出步行路线。但是我想知道我是否可以让 R 为我设计路线?
在
poly
中R能计算出这样的步行路线吗?
library(sf); library(tibble); library(dplyr)
lon <- c(-2.28693776739262, -2.28775699708943, -2.28703948292762, -2.29244089927134, -2.29166515832837, -2.30186223039892, -2.30309391144779, -2.3056785372324, -2.30317524849752, -2.29377665148526, -2.28749981389358, -2.28693776739262)
lat <- c(55.8178060589878, 55.8176446224019, 55.8143145424301, 55.8134429653489, 55.8125449362038, 55.8111356982306, 55.8143414682509, 55.8151103263674, 55.8178015760052, 55.8220786729108, 55.8200414980507, 55.8178060589878)
df <- tibble(lon, lat)
poly <- df %>%
st_as_sf(coords = c("lon", "lat"), crs = 4326) %>%
summarise(geometry = st_combine(geometry)) %>%
st_cast("POLYGON")