I have a three individual lists in Python, all of which are quite large. A stipulation is that the lists cannot be reordered from how they are currently shown. A snippet of how each list looks is as follows:
lats = [40.92322342,40.92322342,40.92322342,40.92322342,40.92322342]
lons = [-74.32176109,-74.29518277,-74.26860445,-74.24202613,-74.21544781]
data = [19,19,19,17,18]
I am looking to provide a latitude and longitude pairing, and would like to return the index number and corresponding value of the data
list that matches the closest to both the provided latitude and longitude.
For example, the pairing 40.9254, -74.2765
would return the corresponding index number, which would be the third set of values in the list snippet provided above.
Using this example, I've been able to partition this search by individual list and return the corresponding index number. However, the index numbers are different.
Code:
min(enumerate(lats), key=lambda x: abs(x[1]-40.9254))
min(enumerate(lons), key=lambda x: abs(x[1]-(-74.2765)))
an index #, 40.92322342
a different index # than above, -74.26860445
Are there any effective ways to solve this problem?