I want to subset from the df the rows in which the corresponding lat/long fall within a 100km radius from the following coordinate point:
lat = 25.70 long = 75.80 It should select at least 4 data rows, I guess by looking at the map.
library(ggplot2)
library(ggmap)
df <- data.frame(
id = as.numeric(c(1:18)),
latitude = as.numeric(c(22.24, 23.20, 24.22, 25.02, 25.88, 26.13, 25.05, 23.93, 22.55, 26.18, 25.45, 24.01, 22.88, 26.13, 25.63, 24.43, 23.41, 26.20)),
longitude = as.numeric(c(-79.68, -79.84, -80.15, -80.01, -80.18, -78.55, -78.37, -78.24, -77.94, -76.13, -76.08, -76.13, -76.11, -75.17, -75.19, -75.29, -75.23, -75.66)))
area1 = get_map(location = c(lon = -77.9407, lat = 24.5774), zoom = 7, maptype = "satellite")
map1 = ggmap(area1, extent = "panel", legend = "bottomright")
map1+geom_point(aes(x = longitude, y = latitude), data = df, color = "#ff0000")
I am trying to do this task but unfortunately I still didn't find a way to manage this. Maybe you guys more experienced can help me to work out this data manipulation issue.