I have a dataset with venue_id (about 1,500 of them), physical address, latitude, and longitude.
I want to create a column named 'overlap', which counts the number of overlapping venue_ids if any.
So for example, for venue_id == 1, within 2km radius if there are any other venue_ids that overlaps in terms of 2km radius, count it and save it in column 'overlap'. If there are 2 venue_ids that overlaps with venue_id == 1, 'overlap' would equal to 2.
So far, I tried first visualizing it with 'folium'
import pandas as pd
import folium
m = folium.Map(location=[37.553975551114476, 126.97545224493899],
zoom_start=10)
locations = df['lat'], df['lng']
df = df.dropna(how='any')
print(df.isna().sum())
for _, row in df.iterrows():
folium.Circle(location=[row['lat'], row['lng']],
radius=2000).add_to(m)
m.save("index.html")
The problem is that folium's Circle would draw a circle in 'pixel' if I understand correctly, and it is fixed to the base 'zoom-level' I've selected creating the base map.
- My best guess is to utilize 'haversine' package, but if there are better ways to do the job, would any of you be able to provide some advice?
p.s. There is no need to actually visualize the result as long as that 2km radius measurements are correctly calculated, I've only tried visualizing it through folium to see if I can 'manually' count the overlapping circles...
Thanks in advance.