R语言sfnetworks包,随机数构建sf线段转为sfnet对象
手动构建sfnet对象
# Fri Jul 30 23:31:26 2021 ----diy--------------------------
# 手动构建sf散点
p1 = st_point(c(113,23))
p2 = st_point(c(114,23.5))
p3 = st_point(c(113.2, 23.7))
p4 = st_point(c(113.9,23.9))
# 用散点构建非闭合线段
# map.l <- st_multipoint(c(p1, p4, p3, p2)) %>%
map.l1 <- st_multipoint(c(p1, p2)) %>%
st_cast('LINESTRING') %>%
st_sfc(crs = 4326)
plot(map.l1)
map.l2 <- st_multipoint(c(p3,p4)) %>%
st_cast('LINESTRING') %>%
st_sfc(crs = 4326)
plot(map.l2)
map.l <- c(map.l1,map.l2)
plot(map.l)
# Sat Jul 31 00:32:29 2021 --转换为sfnet对象
net <- as_sfnetwork(map.l)# |>
# st_transform(3035)
plot(net)
sfnet对象
随机散点构建的sf非闭合线段
网友评论