I'm creating a map in Folium and it is working great, except several hundred markers aren't showing up on the map. There is no error message, I just notice that there are fewer markers than I expect.
from dwca.read import DwCAReader
from dwca.darwincore.utils import qualname as qn
from pygbif import maps
import folium
import pandas as pd
import branca
with DwCAReader('data/University_DwC-A.zip') as dwca:
print ("Core data file is: {}".format(dwca.descriptor.core.file_location))
df = dwca.pd_read('occurrences.csv', parse_dates=True, low_memory=False)
location = df[df["locality"].str.contains('myLocationOfInterest', na=False)]
location_dropna = location[location["decimalLatitude"].notna()]
location_dropna = location_dropna[location_dropna["decimalLongitude"].notna()]
obs = location_dropna[["decimalLatitude", "decimalLongitude","scientificName", "habitat", "locality", "eventDate", "recordedBy"]].reset_index()
def popup_html(row):
i = row
scientificName=obs['scientificName'].iloc[i]
habitat=obs['habitat'].iloc[i]
locality = obs['locality'].iloc[i]
obsDate=obs['eventDate'].iloc[i]
recordedBy = obs['recordedBy'].iloc[i]
left_col_color = "#19a7bd"
right_col_color = "#f2f0d3"
html = """<!DOCTYPE html>
<html>
<head>
<h4 style="margin-bottom:10"; width="200px"; font-size:30px>{}</h4>""".format(scientificName) + """
</head>
<table style="height: 126px; width: 350px;">
<tbody>
<tr>
<td style="background-color: """+ left_col_color +""";"><span style="color: #ffffff;">Habitat</span></td>
<td style="width: 150px;background-color: """+ right_col_color +""";">{}</td>""".format(habitat) + """
</tr>
<tr>
<td style="background-color: """+ left_col_color +""";"><span style="color: #ffffff;">Locality</span></td>
<td style="width: 150px;background-color: """+ right_col_color +""";">{}</td>""".format(locality) + """
</tr>
<tr>
<td style="background-color: """+ left_col_color +""";"><span style="color: #ffffff;">Observation Date</span></td>
<td style="width: 150px;background-color: """+ right_col_color +""";">{}</td>""".format(obsDate) + """
</tr>
<tr>
<td style="background-color: """+ left_col_color +""";"><span style="color: #ffffff;">Recorded By</span></td>
<td style="width: 150px;background-color: """+ right_col_color +""";">{}</td>""".format(recordedBy) + """
</tr>
</tbody>
</table>
</html>
"""
return html
obs_mean_location = obs_locations.decimalLatitude.mean(), obs_locations.decimalLongitude.mean()
myMap = folium.Map(location = obs_mean_location, zoom_start=14.5, control_scale=True)
for i, location_info in obs.iterrows():
html = popup_html(i)
iframe = branca.element.IFrame(html=html, width=510, height=280)
popup = folium.Popup(folium.Html(html, script=True), max_width=500)
folium.Marker([location_info["decimalLatitude"], location_info["decimalLongitude"]],
popup=popup).add_to(myMap)
myMap
obs
contains nearly 500 records but I end up seeing maybe less than 50 on the map. How can I make sure I see every record on my map?