我有五个经纬度,它们形成了这样的一个形状。
df <- c(order=1:5,
lon=c(119.4,119.4,119.4,119.5,119.5),
lat=c(-5.192,-5.192,-5.187,-5.187,-5.191))
我怎样才能使用sf
包将它们轻松地转换为sf多边形数据框架呢?
## Simple feature collection with 1 feature and 0 fields
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: 119.4 ymin: -5.192 xmax: 119.5 ymax: -5.187
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
## geometry
## 1 POLYGON ((119.4 ...
group_by
进行分组。例如,对于两个多边形,我提供了以下数据框:df <- tibble(AC_NO = c(100, 101), lon = list(c(76.4, 76.38, 76.4, 76.38), c(76.4, 76.38, 76.4, 76.38)), lat = list(c(9.58, 9.58, 9.56, 9.56), c(9.55, 9.55, 9.53, 9.53)))
然后:df %>% group_by(AC_NO) %>% st_as_sf(
等等。我收到一个错误,指出 "list" 无法强制转换为类型 "double"。有什么想法我做错了什么吗? - Fons MA