我正在尝试创建漂亮的聚集点图形。是否有一个包可以在点的镶嵌之间创建分界链?理想情况下,它适合在ggplot
.
这是一些示例代码:
#DivideLineExample
library(spatstat)
W=owin(c(0,1),c(0,1)) # Set up the Window
p<-runifpoint(42, win=W) # Get random points
ll=cbind(p$x,p$y) # get lat/long for each point
zclust=kmeans(ll,centers=4) # Cluster the points spatially into 4 clusters
K<-pp<-D<-list()
plot(W,main="Clustered Points")
for (i in 1:4){ # this breaks up the points into separate ppp objects for each cluster
K[[i]]=ll[zclust$cluster==i,]
pp[[i]]=as.ppp(K[[i]],W)
plot(pp[[i]],col=i,add=TRUE,cex=1.5,pch=16)
D[[i]]=dirichlet(pp[[i]]) # This performs the Dirichlet Tessellation and plots
plot(D[[i]],col=i,add=TRUE)
}
这输出如下:http: //imgur.com/CCXeOEB
我正在寻找的是这个:http: //imgur.com/7nmtXjo
我知道存在一种算法。
有什么想法/替代方案吗?