0

I have a GPS tracker plugged in my USB-port, now this GPS tracker gives me my current location in coordinates like this (53.545, 9.658). Now I also have an excel file which contains hundred of similar coordinates. I want my code to search in that Excel file for the values that are nearest to my GPS coordinates (53.545, 9.658) and simply print that row for me.

This is my code:

import pandas as pd

    df = pd.read_excel("my_coordinates")

def closest(df, v): 
      
    return df[min(range(len(df)), key = lambda i: abs(df[i]-v))] 
    v = (53.545, 9.658)

print(df, v)
Premier12
  • 69
  • 5
  • see : https://gis.stackexchange.com/questions/222315/geopandas-find-nearest-point-in-other-dataframe – Umar.H Jul 27 '20 at 12:54
  • Split df to columns https://stackoverflow.com/q/29550414/6692898 Then calc distance with https://stackoverflow.com/a/19412565/6692898 using full columns as args, avoid itertuples – RichieV Jul 27 '20 at 14:07

0 Answers0