spatial clustering in R (simple example)

前端 未结 3 943
抹茶落季
抹茶落季 2021-02-04 14:49

I have this simple data.frame

 lat<-c(1,2,3,10,11,12,20,21,22,23)
 lon<-c(5,6,7,30,31,32,50,51,52,53)
 data=data.frame(lat,lon)
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-04 15:25

    What about something like this:

    lat<-c(1,2,3,10,11,12,20,21,22,23)
    lon<-c(5,6,7,30,31,32,50,51,52,53)
    
    km <- kmeans(cbind(lat, lon), centers = 3)
    plot(lon, lat, col = km$cluster, pch = 20)
    

    enter image description here

提交回复
热议问题