R中的SpatialPointsDataFrame引发无效的参数Type。!res [1]错误

时间:2020-06-04 15:17:10

标签: spatial

library('sp')
library(rgdal)
library(geosphere)

x <- c(-1.482156, -1.482318, -1.482129, -1.482880, -1.485735, -1.485770, -1.485913, -1.484275, -1.485866)
y <- c(54.90083, 54.90078, 54.90077, 54.90011, 54.89936, 54.89935, 54.89935, 54.89879, 54.89902)

xy <- SpatialPointsDataFrame(matrix(c(x,y), ncol=2),data.frame(ID=seq(1:length(x))),proj4string=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84"))

mdist <- distm(xy)

hc <- hclust(as.dist(mdist), method="complete")

d=40

xy$clust <- cutree(hc, h=d)

基于R中的纬度和经度进行聚类。

0 个答案:

没有答案