小编Sha*_*haz的帖子

在R中提取形状文件对象的质心?

我有一个形状文件,上传到以下路径:

https://drive.google.com/open?id=0B1ITb_7lHh1EUFVfVWc4ekRfSnc

我使用“shapefiles”包中的“read.shapefiles”函数导入了数据:

landuse<- read.shapefile("landuse")
Run Code Online (Sandbox Code Playgroud)

我现在需要提取 landuse 对象内所有形状的纬度/经度质心并将其添加到 landuse$dbf 数据帧

我尝试了两件事:

lu_df<-coordinates(landuse)
lu_df<-SpatialPoints(landuse)
Run Code Online (Sandbox Code Playgroud)

两者都给了我以下错误:

Error in coordinates(as.data.frame(obj)) : 
  error in evaluating the argument 'obj' in selecting a method for function 'coordinates': Error in data.frame(record = 1L, content.length = 80L, shape.type = 5L,  : 
  arguments imply differing number of rows: 1, 4, 7
Run Code Online (Sandbox Code Playgroud)

我不确定如何进行。

r geospatial shapefile centroid

3
推荐指数
1
解决办法
3801
查看次数

标签 统计

centroid ×1

geospatial ×1

r ×1

shapefile ×1