I have two list of coordinates, mapped_coords, unmapped_coords that are both a list of coordinates.
I want to take the unmapped_coords and for every element return the index of the point with the min distance in mapped_coord.
> head(mapped_coords)
[[1]]
[1] -79.2939 43.8234
[[2]]
[1] -79.7598 43.4381
[[3]]
[1] -79.4569 43.6693
[[4]]
[1] -81.2472 42.9688
[[5]]
[1] -79.1649 43.8073
[[6]]
[1] -79.7388 43.6753
str(mapped_coords)
List of 62815
$ : num [1:2] -79.3 43.8
$ : num [1:2] -79.8 43.4
$ : num [1:2] -79.5 43.7
Using the geosphere package I can use distHaversine to calculate the distance of a a pair but I'm not sure of how to do it over the entire list.
> distHaversine(unlist(unmapped_coords[1]), unlist(mapped_coords[1]))
[1] 100594.6