Pysal: folium breakage

Created on 30 Oct 2017  路  9Comments  路  Source: pysal/pysal

In testing: folium_mapping.ipynb it appears folium has changed an api as our example is broken.

fm.choropleth_map('./example.json', 'FIPS', 'HR90')

AttributeError Traceback (most recent call last)
in ()
----> 1 fm.choropleth_map('./example.json', 'FIPS', 'HR90')

/Users/serge/Dropbox/p/pysal/src/pysal/pysal/contrib/viz/folium_mapping.pyc in choropleth_map(jsonpath, key, attribute, df, classification, classes, bins, std, centroid, zoom_start, tiles, fill_color, fill_opacity, line_opacity, legend_name, save)
249
250 #folium call, try abstracting to a "mapper" function, passing list of args
--> 251 choromap.geo_json(geo_path=jsonpath, key_on = jsonkey,
252 data = df, columns = dfkey,
253 fill_color = fill_color, fill_opacity = fill_opacity,

AttributeError: 'Map' object has no attribute 'geo_json'

Most helpful comment

@ZhihaoJia16 thanks for the code snippet in the bug report.

It appears as if you are using folium directly and not via pysal - is this the intention?
If so, please redirect your bug report to the folium project. If not, we would need more context to help you debug.

All 9 comments

This should be fixed?

@weikang9009 reported this in a previous issue. and I thought I addressed it in #835, but now when I view that PR, it looks empty. I've never seen an empty PR, & it clearly didn't make it upriver. I'll pull in that fix & sub.

The bug is in 1.14.2 as we are testing it on the workshop materials.

I've fixed the issue, but now (for some reason) any plotting of the folium map inline with the jupyter notebook fails if the map exceeds a given number of features.
ratelimit
What a bummer.
I've subset it to texas & it works fine:
working

I'd like to update the notebook segment. I can submit those changes to both your workshop repo & this, if that's alright?

I've fixed the issue, but now (for some reason) any plotting of the folium map inline with the jupyter notebook fails if the map exceeds a given number of features. What a bummer.

Indeed :-( but that limitation is new in the latest jupyter notebook format and not folium.
One workaround it to is to start jupyter with

jupyter notebook --no-browser --NotebookApp.iopub_data_rate_limit=1000000000

Ah! good to know.

Now, I met the similar problem:

AttributeError Traceback (most recent call last)
in ()
1 map = folium.Map(location=[40.748817, -73.985428], zoom_start=13)
----> 2 map.geo_json(geo_path=r'C:/Users/j00422098/Desktop/Python/PythonPackage/jupyter/USA.json', data=su_lt_two,
3 columns=['Zip', 'Rent'],
4 key_on='feature.properties.postalCode',
5 threshold_scale=[1700.00, 1900.00, 2100.00, 2300.00, 2500.00, 2750.00],

AttributeError: 'Map' object has no attribute 'geo_json'

Code as follows:

import folium
map = folium.Map(location=[40.748817, -73.985428], zoom_start=13)
map.geo_json(geo_path=r'C:/Users/j00422098/Desktop/Python/PythonPackage/jupyter/USA.json', data=su_lt_two,
columns=['Zip', 'Rent'],
key_on='feature.properties.postalCode',
threshold_scale=[1700.00, 1900.00, 2100.00, 2300.00, 2500.00, 2750.00],
fill_color='YlOrRd', fill_opacity=0.7, line_opacity=0.2,
legend_name='Rent (%)',
reset=True)
map.create_map(path='nyc.html')

@ZhihaoJia16 thanks for the code snippet in the bug report.

It appears as if you are using folium directly and not via pysal - is this the intention?
If so, please redirect your bug report to the folium project. If not, we would need more context to help you debug.

similar problem, how can I fix it? check the offical folium project?

@JiaJingnan if it is the same problem as @ZhihaoJia16 then I would suggest checking with the folium project.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sjsrey picture sjsrey  路  11Comments

barguzin picture barguzin  路  6Comments

rsbivand picture rsbivand  路  8Comments

sjsrey picture sjsrey  路  20Comments

sjsrey picture sjsrey  路  13Comments