question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unable to use FastMarkerCluster with anything more than lat/lng pairs in data

See original GitHub issue

Hello,

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:closed
  • Created 5 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
ramesesjdcommented, Mar 21, 2019

Thank you!

0reactions
Conengmocommented, Mar 20, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use customized markers in FastMarkerCluster in Python folium?
I'm able to add data to a folium map using MarkerCluster and vary the parameters of the marker according to parameters for each...
Read more >
[Copy & Fix] House_Price_Prediction 1 - 2 | Kaggle
In this notebook, we will first apply some Exploratory Data Analysis (EDA) ... but we'll want something with more structure to plot out...
Read more >
plugins — Folium 0.12.1 documentation - GitHub Pages
Using FastMarkerCluster it is possible to render 000's of points far quicker ... method is never called, and no reference to any marker...
Read more >
2020年10月_weixin_39906192的博客_CSDN博客
everything 便携版和安装版区别_Everything,一秒搜出想要的文件,unity需要什么配置_BIM软件需要什么样的电脑配置?,java商城_纯分享Java开发大型电商系统XX商城实战视频 ...
Read more >
Adding text to Folium FastMarkerCluster markers
I believe the problem has something to do use of case with the fact that the df containing the United text column is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found