r - 提取多边形和中心作为 sf 中的列
问题描述
我有一个sf
具有这种结构的样式数据框:
Classes ‘sf’ and 'data.frame': 1672 obs. of 3 variables:
'$ grid.100:sfc_POLYGON of length 1672; first list element: List of 1
' ..$ : num [1:5, 1:2] 542829 543129 543129 542829 542829 ...
..- attr(*, "class")= chr "XY" "POLYGON" "sfg"
' $ id : int 1 2 3 4 5 6 7 8 9 10 ...
' $ count : int 0 0 0 0 0 0 0 0 1 0 ...
- attr(*, "sf_column")= chr "grid.100"
- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA
..- attr(*, "names")= chr "id" "count"
我想要做的是从 POLYGON 特征中提取各个坐标,因此多边形的每一侧都是数据框中自己的列。
有什么想法吗?
解决方案
我想通了,我认为:
grid.sff <- grid.sf %>%
dplyr::mutate(latt = sf::st_coordinates(grid.sf$center)[,1]) %>%
dplyr::mutate(lonn = sf::st_coordinates(grid.sf$center)[,2])
推荐阅读
- javascript - Javascript 大于 (>) 运算符无法正常工作
- database - 我可以使用 Vividus 工具查询哪些数据库
- c# - 如何在启动时使用 dotnet core 3 中的依赖项调用自定义服务?
- sql-server - 在不同帐户下使用 T-SQL 运行 SSIS 包
- python - 多次调用运行异步函数的函数:将事件循环放在哪里?
- yaml - Elastic Beanstalk 部署后在 Windows 服务器上执行 powershell 脚本
- apache-spark - 为什么读取 parquet 文件时出现“不是 Parquet 文件”错误
- arrays - 从可能有逗号或空格的字符串创建标签数组
- ios - 执行获取请求时崩溃 - [NSTemporaryObjectID_default compare:]:无法识别的选择器发送到实例
- django - Django,url配置反向题。给出不正确的配置