0
我想使用k-medoids聚類地理信息。在考慮地球曲率的同時,我需要集中在緯度,經度和深度上。R中的地理數據上的聚類Shiny
我的最終目標是將數據繪製爲地圖,併爲不同區域使用不同的顏色。這裏是繪製和打印數據的現有ggplot(但只包括緯度,經度和不必要的大小),並沒有考慮深度或聚類。
pp <- ggplot() +
geom_polygon(aes(long,lat, group=group), fill="palegreen3", colour="grey60", data=county) +
geom_polygon(data=states, aes(x=long, y=lat, group = group),colour="royalblue4", fill=NA) +
annotate("rect", xmin=-84, xmax=-71, ymin=35.5, ymax=43.5, colour="black", size=1, fill="blue", alpha="0.01") +
geom_point(data=plotdata, size=3, alpha = .7, aes(x=lon, y=lat, color=emw)) +
theme(plot.background = element_rect(fill = 'grey')) +
geom_abline(intercept = 3, slope = -.45, color = "grey", size = 1)
print(pp)
下面是用於ggplot樣本數據集(沒有深度或集羣):
target_states <- c("pennsylvania", "new york", "new jersey", "virginia", "kentucky","rhode island",
"massachusetts","vermont","new hampshire", "delaware", "maryland", "west virginia",
"north carolina", "tennessee", "ohio", "connecticut", "district of columbia")
all_states <- map_data("state")
county <- map_data("county")
plotdata <- structure(list(lat = c(50L, -30L, -33L), lon = c(-40L, -30L, -50L), mag = c(3.5, 1.1, 2.3)), .Names = c("lat", "lon", "mag"), class = "data.frame", row.names = c(NA, -3L))
任何建議,如何更好地實現這一目標?