1
我有一個圍繞中心點的緯度數據框。拉通代表兩組。這些組以1或0表示。我可以圍繞中心點繪製不同的形狀 和顏色,但是我希望顏色更清晰。我還想分別圍繞300米和600米兩點劃兩圈。我曾嘗試與圍繞數據中心點繪製兩個圓圈
Plot circle with a certain radius around point on a map in ggplot2
工作,但有沒有運氣
一個小樣本看起來像這樣
lat <- c(42.99052, 42.99085, 42.99046, 42.99081, 42.99197, 42.99122, 42.99154,42.99161, 42.99102, 42.99014, 42.98966, 42.99091, 42.99092, 42.99114 ,42.99000)
lon <-c(78.69961, -78.69871, -78.69878, -78.69868, -78.69825, -78.69929, -78.69784, -78.69960, -78.69904, -78.69918, -78.69998, -78.69746, -78.70145, -78.70020, -78.70010)
response <- c(0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1)
data <- data.frame(lat, lon, response)
我的中心點是
(42.990707, -78.698899)
我得到我的沒有圓圈和不同顏色的地圖,像這樣
library(ggplot2)
library(ggmap)
library(viridis)
#getting map
mapgilbert <- get_map(location = c(lon = -78.698899 , lat=42.990707), zoom = 17,
maptype = "terrain", scale = 2)
ggmap(mapgilbert) +
geom_point(data = data, aes(x = lon, y = lat, color = response , alpha = 1, fill = response),
size = 2, shape = response) +
guides(fill = FALSE, alpha = FALSE, size = FALSE) +
scale_color_viridis(begin = 0, end = .7)
任何幫助,將不勝感激。
得到了解決,我建議您按照從您鏈接到的問題這樣的回答:https://stackoverflow.com/a/34187878/ 7446435您可能需要了解一些關於投影的內容,但它基本上是最簡單的方法,可以準確獲得您所需的內容。 – Jul
@ Mikel Arnaiz,你爲什麼要畫圈子? ;-) –