import folium
import pandas as pd

"""
Explanation: End-To-End Example: Plotting and Mapping Potholes
Let's do a data analysis of Syracuse Potholes based on data from the civic hackathon https://cityofsyracuse.github.io/RoadsChallenge/ 
We will plot data and display pothole locations on a map!
End of explanation
"""


SYR = (43.0481, -76.1474)
map = folium.Map(location=SYR, zoom_start=14)
map

"""
Explanation: First we need to find the latitude and longitude of Syracuse, then estimate the appropriate zoom level...
End of explanation
"""


data = pd.read_csv('https://cityofsyracuse.github.io/RoadsChallenge/data/potholes.csv')
data.sample(5)

"""
Explanation: We get the data from the RoadsChallange github account
End of explanation
"""


# NOTE: to_dict('records') converts a pandas dataframe back to a list of dict!
SYR = (43.0481, -76.1474)
map = folium.Map(location=SYR, zoom_start=14)
subset = data.sample(500)
for row in subset.to_records():
    coords = (row['Longitude'],row['Latitude'])
    loc = str(row['strLocation']) + ' ' + str(row['dtTime'])
    marker = folium.Circle(location=coords, radius=15, popup=loc,color='#3186cc',fill_color='#3186cc')
    map.add_child(marker)
    
map

"""
Explanation: Now we take the latitude and longitude of each pothole and show them on a map using circle markers
End of explanation
"""


