【问题标题】:how to dissolve a polyline in R如何在R中溶解折线
【发布时间】:2020-10-09 16:12:39
【问题描述】:

我有一个需要解散的大型折线 shapefile。但是,在线示例仅涉及多边形而不是折线,例如gUnaryUnion。我正在使用 sf 包中的 st_read 阅读我的 shapefile。任何帮助,将不胜感激。

【问题讨论】:

  • 联合不是行上定义明确的操作 - 您的预期结果是什么?
  • 我设法使用st_combine 实现了我所需要的。

标签: r gis polyline sf sp


【解决方案1】:

如果我理解您的问题,一种选择是使用dplyr

library(sf)
library(dplyr)

# get polyline road data
temp_shapefile <- tempfile()
download.file("https://www2.census.gov/geo/tiger/TIGER2017//ROADS/tl_2017_06075_roads.zip", temp_shapefile)
temp_dir <- tempdir()
unzip(temp_shapefile, exdir = temp_dir)

sf_roads <- read_sf(file.path(temp_dir,'tl_2017_06075_roads.shp'))

使用 RTTYP 字段将折线从约 4000 个唯一线段减少到 6 个线段。

sf_roads_summarized <- sf_roads %>%
  group_by(RTTYP) %>%
  summarize()

【讨论】:

    【解决方案2】:

    我设法通过使用st_combine 来实现这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-21
      • 1970-01-01
      • 1970-01-01
      • 2019-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多