Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting choropleth layer name #589

Closed
ahlevering opened this issue Jan 31, 2017 · 1 comment
Closed

Setting choropleth layer name #589

ahlevering opened this issue Jan 31, 2017 · 1 comment

Comments

@ahlevering
Copy link

ahlevering commented Jan 31, 2017

Dearest all,

I've been using Folium for a group assignment and am loving what I can do with it so far. However, I run into troubles when trying to set the name for choropleth layers. While GeoJSON and TopoJSON formats have 'name' arguments that can be passed to the function, the choropleth function does not. As such, it appears as "macro_element_0a4d2f76a5a84a7084882de74056b4dd" in the layer list. I haven't found a passable argument or workaround for this problem.

I'm using the following code to add the choropleths:

tweet_map.choropleth(geo_path = polygon_geojson, data = polygon_data,
             columns=['name', 'avgsentiment'],
             threshold_scale = [-0.25, -0.125, 0, 0.125, 0.25],
             key_on = 'feature.properties.name',
             fill_color = 'RdYlGn', fill_opacity = 0.7, line_opacity = 0.5,
             legend_name = 'average sentiment',
             reset=True)

Am I missing something obvious or is there no easy way to set the layer name?

Yours truly,
Alex

EDIT: Setting the legend name does not help. It still displays as 'macro_element'. Additionally, I should mention that I add two choropleths to the same map. Perhaps this could cause problems as well?

@ocefpaf
Copy link
Member

ocefpaf commented Mar 6, 2017

The choropleth method is old and we are probably deprecating it. The "right" way to do this is via the GeoJson class.

There is an example in cell 11 of http://nbviewer.jupyter.org/github/python-visualization/folium/blob/master/examples/GeoJSON_and_choropleth.ipynb?flush_cache=true

PS: I may be persuade to add this to the choropleth with a PR 🎐

@ocefpaf ocefpaf closed this as completed Mar 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants