I have two data-frames with longitude and latitudes coordinates. df1 has 20 coordinates and df2 has 600 coordinates. What I am trying got do is to take each coordinate in df1 and find the closest coordinate in df. For example the first coordinate in df1 is 52.2296756, 21.0122287, so i have to create the loop somehow to take these two values and calculate the distance against every coordinate in df2 and return the one with the shortest distance.
I have this code so far:
import geopy.distance
import pandas as pd
coords_1 = (52.2296756, 21.0122287)
coords_2 = (52.406374, 16.9251681)
print(geopy.distance.vincenty(coords_1, coords_2).km)
How would i write this function to take the first coordinate from df1 and perform calculation against every coordinates in df and return the closest one?