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.

Cluster Effect - 'You cannot render this Element ' 'if it is not in a Figure.'

See original GitHub issue

Problem description

Mapping markers for charter schools across the United States has worked. I’m now trying to apply a cluster method to this. The code below runs without an error. When I add a cell and run ‘mappo’ to see if the cluster effect has worked. I get the error mentioned in the last part of this post.

#MAIN METHOD THAT RETURNS CHOROPLETH MAP WITH POINTS

charterdropped.crs = sdshape.crs
charterdropped = charterdropped.to_crs(epsg='4326')
cjson = charterdropped.to_json()
mappo = folium.Map([37.7556, -122.4399], zoom_start = 7)

mappo.choropleth(
    geo_data=districtchanged,
    data=districtchanged,
    columns=['FIPS', '% Total Population: White Alone'],
    key_on='feature.properties.FIPS',
    legend_name='White people', 
    fill_color='YlGn',
    fill_opacity=0.4,
    highlight=True) 
points = folium.features.GeoJson(cjson)
mappo.add_child(points)


#Cluster Method

marker_cluster = MarkerCluster().add_to(mappo)
for each in charterdropped[0:len(charterdropped)].iterrows():
    folium.Marker(
            location=[each[1]['latitude'], each[1]['longitude']],
            popup=folium.Popup(
                            folium.IFrame(
                                html=each[1]['SCH_NAME'])
                
                                         
            ).add_to(marker_cluster))
    

Output of ``folium.version

assert isinstance(figure, Figure), ('You cannot render this Element ' 'if it is not in a Figure.')

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Conengmocommented, Oct 30, 2018

Good to hear your problem is solved!

0reactions
sarahsoliemancommented, Oct 30, 2018

Thanks for your suggestions @Conengmo. I figured out a solution. Something that was important for me to do was switch the ordering of latitude and longitude. (x,y) --> (y,x). I believe perhaps maybe they were mislabeled in data handling.

locations = charterdroppedlol[['longitude','latitude']]
locationlist = locations.values.tolist()
locationlist 


mapclus = folium.Map(location=[37.7556, -122.4399], zoom_start=7)
marker_cluster = MarkerCluster().add_to(mapclus)

for point in range(0, len(locationlist)):
    folium.Marker(locationlist[point], popup="hi").add_to(marker_cluster)
mapclus.save('clustercalifornia.html')
Read more comments on GitHub >

github_iconTop Results From Across the Web

Assertion error in Folium - "cannot render this Element if it's ...
However, when I try to save the map as an HTML file, I get an Assertion Error: "You cannot render this Element if...
Read more >
python-visualization/folium - Gitter
json()['features'] ), I get the following error. ValueError: Cannot render objects with any missing geometries: and the error continues to return entries from ......
Read more >
Graph visualization in the Neptune workbench
This diagram identifies user-interface elements present in the Graph tab: ... Once the Neptune workbench opens, running Jupyter, you will see a Neptune ......
Read more >
Fix common cluster issues | Elasticsearch Guide [8.5] | Elastic
A red or yellow cluster status indicates one or more shards are missing or unallocated. These unassigned shards increase your risk of data...
Read more >
FAQ - Graphviz
If you cannot find the answer to your question here, ask it in the ... How can I set a graph or cluster...
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