Plot circle with a certain radius around point on a map in ggplot2

后端 未结 5 431
情话喂你
情话喂你 2020-12-09 04:37

I have a map with the 8 points plotted on it:

library(ggplot2)
library(ggmap)
data = data.frame(
    ID = as.numeric(c(1:8)),
    longitude = as.numeric(c(-6         


        
5条回答
  •  猫巷女王i
    2020-12-09 05:11

    Calculating distance in km given latitude and longitude isn't super straightforward; 1 degree lat/long is a greater distance at the equator than at the poles, for example. If you want an easy workaround that you can eyeball for accuracy, you might try:

    islandMap + RL + 
      scale_x_continuous(limits = c(-63.280, -63.21), expand = c(0, 0)) + 
      scale_y_continuous(limits = c(17.605, 17.66), expand = c(0, 0)) + 
      geom_point(aes(x = longitude, y = latitude), data = data, size = 20, shape = 1,  color = "#ff0000")
    

    You'll need to adjust the size paramter in the 2nd geom_point to get closer to what you want. I hope that helps!

提交回复
热议问题