I’m making a map using a single spreadsheet of data, as some facilities meet certain criteria that others don’t, that I’d like to filter out into a separate layer that can be selected on the map.
I’m fresh into python, but picking it up fairly easily.
Here’s my code so far:
import pandas as pd import folium df=pd.read_excel(open('data/VA Healthcare Facilities.xlsx', "rb")) # Define Various Global Variables location=[47.1164,-101.2996] locationlist=df[["Latitude","Longitude"]].values.tolist() labels=df["Name"].values.tolist() surgical=df["Surgical"].values.tolist() map=folium.Map(location=location,zoom_start=4,tiles="CartoDB positron") from folium.plugins import MeasureControl map.add_child(MeasureControl()) fg=folium.FeatureGroup(name="All VA Healthcare Facilities") for point in range(len(locationlist)): popup=folium.Popup(labels[point],parse_html=True) fg.add_child(folium.RegularPolygonMarker( locationlist[point], popup=popup, fill_color='#EE1C25', number_of_sides=5, radius=7, )).add_to(map) map.add_child(fg) fg2=folium.FeatureGroup(name="VA Surgical Facilities") map.add_child(fg2) map.add_child(folium.LayerControl()) map.save(outfile="Healthcare_Facilities.html")
Within the excel spreadsheet, I’ve created a row for noting surgical capability, 1 meaning yes, and 0 meaning no. I’m certain an if/else statement could be what I need to parse this data and pull the coordinates from “locationlist” to plot only those with the value of “1” on the new layer. The idea is being able to toggle between all facilities, and only those with surgical capability. There will be additional layers likely created using the same method, but I just need to get it down first. Any suggestions?
I realize I could just use additional sheets of data, but I’d like to keep it all consolidated for ease of updating.