R根据属性删除重复的空间点
R remove duplicate spatial points according an attribute
在 R 中,我有一个带有重复点(坐标和属性)的 SpatialPointsDataFrame,我想删除所有具有相同数据的点...
我在 sp
包中找到了 remove.duplicates()
函数,但它似乎只在位置上删除...还有其他方法吗?
谢谢
E.
这样的东西行得通吗?
library(sp)
pts <- SpatialPoints(cbind(c(1, 1, 1, 2, 3, 4), c(1, 1, 1, 4, 2, 4)))
pts <- SpatialPointsDataFrame(pts, data=data.frame(id = c(1, 2, 2, 3, 4, 5)))
## All points
pts
## No spatial duplicates
remove.duplicates(pts)
## No duplicates in attributes
pts[which(!duplicated(pts$id)), ]
## Combination
pts[which(!duplicated(as.data.frame(pts))), ]
在 R 中,我有一个带有重复点(坐标和属性)的 SpatialPointsDataFrame,我想删除所有具有相同数据的点...
我在 sp
包中找到了 remove.duplicates()
函数,但它似乎只在位置上删除...还有其他方法吗?
谢谢
E.
这样的东西行得通吗?
library(sp)
pts <- SpatialPoints(cbind(c(1, 1, 1, 2, 3, 4), c(1, 1, 1, 4, 2, 4)))
pts <- SpatialPointsDataFrame(pts, data=data.frame(id = c(1, 2, 2, 3, 4, 5)))
## All points
pts
## No spatial duplicates
remove.duplicates(pts)
## No duplicates in attributes
pts[which(!duplicated(pts$id)), ]
## Combination
pts[which(!duplicated(as.data.frame(pts))), ]