I have two datasets containing latitudes, longitudes and locations. I would like to link one dataset (the weather stations) to another (the main dataset). But the main dataset has latitude/longitude combinations that don't match up directly to the weather station dataset. Is there a way I can use some sort of nearest neighbor algorithm to find the closest weather station to each of my data points?
Asked
Active
Viewed 59 times
0
-
1Take the `min` of the other dataset with a `key` that expresses the distance from the data point in question. – Samwise Mar 24 '22 at 15:16
-
iterate over the weather stations and pick the one with the minimum distance to your datapoint. You will want to use a geodesic distance for that problem – Mar 24 '22 at 15:16
-
[This answer](https://stackoverflow.com/a/65037569/1566221) is relevant. The standard Python library has no such function. Third-party libraries may exist, but SO doesn't allow questions asking for software recommendations. A geographical database might a better long-term solution. – rici Mar 24 '22 at 15:21