unable to use FastMarkerCluster with anything more than lat/lng pairs in data
See original GitHub issueHello,
Firstly, thanks for all you work on folium; I’m quite new to Python but have some experience with GIS and am really very impressed at how sophisticated folium is.
I’m having some trouble adapting this example (at In [6] and [7]) from @JamesGardiner to my situation. Some example code below to illustrate the problem I’m having.
import pandas as pd
import numpy as np
import folium
import folium.plugins as plugins
lats = np.asarray([-54.4, -54.5, -54.6])
longs = np.asarray([-69.5, -69.5, -69.5])
data = np.asarray([70, 90, 5])
color = np.asarray(['green', 'orange', 'red'])
dummy = [list(a) for a in zip(lats, longs)]
d1map = folium.Map(location = [-54.5, -69.5], zoom_start = 7)
plugins.FastMarkerCluster(dummy).add_to(d1map)
d1map
dummy2 = pd.DataFrame(dummy, columns=['lat', 'lng'])
d2map = folium.Map(location = [-54.5, -69.5], zoom_start = 7)
plugins.FastMarkerCluster(dummy2).add_to(d2map)
d2map ## this gives me 'TypeError: must be real number, not str'
dummy3 = [list(a) for a in zip(lats, longs, data, color)]
dummy3 = pd.DataFrame(dummy3, columns=['lat', 'lng', 'data', 'color'])
d3map = folium.Map(location = [-54.5, -69.5], zoom_start = 7)
plugins.FastMarkerCluster(dummy3).add_to(d3map)
d3map ## this gives me 'TypeError: must be real number, not str'
Problem description
I can combine a list of lat and lng and pass that to FastMarkerCluster and plot the points/clusters. However, converting to a dataframe then to JSON, as in the example notebook above, gives me TypeError: must be real number, not str
. Also, if I combine anything more with the lat and lng, and pass this to FastMarkerCluster, I get a blank map. Converting to a dataframe then converting to JSON gives me the same error as above.
Expected Output
I’d like to produce a map with FastMarkerCluster using callbacks to display popups as in the linked example above, and ideally also show different symbol colours based on the data. I am unable to give FastMarkerCluster anything more than lat/lng pairs, however, preventing me from using the remaining data in a callback.
FYI I can seemingly do this with no problems using MarkerCluster (see my example 1 in SO question here), but my data has several thousand rows so that would be infeasible.
Output of folium.__version__
0.8.2
Many thanks in advance, -Rameses
Issue Analytics
- State:
- Created 5 years ago
- Comments:11
Top GitHub Comments
Thank you!
You got the most recent release from the Pypi package repository, not the our git master branch. You can install it with
pip install git+https://github.com/python-visualization/folium.git
. See also here: https://stackoverflow.com/questions/20101834/pip-install-from-git-repo-branch