geopandas
geopandas copied to clipboard
ENH: check for minimum version of folium
I've found that we require some recent version of folium with explore
. I haven't yet checked which is needed but 0.8.3 that comes pre-installed in Google Colab is too old and raises an error. We should capture that and raise an informative error, instead of existing coming from folium (something about missing 1 required positional argument: “location”
).
In case someone stumbles upon this issue trying to resolve Google Colab, just update folium.
!pip install folium -U
Do you have the full traceback? If it's only about a single keyword, it might also be relatively easy to fix that in geopandas to avoid this small annoyance.
It is not about a keyword, it doesn't work at all. It happens during the initialization of a default marker type (even though the marker itself is not used).
import geopandas
df = geopandas.read_file(geopandas.datasets.get_path("nybb"))
df.explore()
TypeError Traceback (most recent call last)
<ipython-input-3-087623d14df8> in <module>()
2
3 df = geopandas.read_file(geopandas.datasets.get_path("nybb"))
----> 4 df.explore()
1 frames
/usr/local/lib/python3.7/dist-packages/geopandas/explore.py in _explore(df, column, cmap, color, m, tiles, attr, tooltip, popup, highlight, categorical, legend, scheme, k, vmin, vmax, width, height, categories, classification_kwds, control_scale, marker_type, marker_kwds, style_kwds, highlight_kwds, missing_kwds, tooltip_kwds, popup_kwds, legend_kwds, **kwargs)
511 marker_kwds["radius"] = marker_kwds.get("radius", 2)
512 marker_kwds["fill"] = marker_kwds.get("fill", True)
--> 513 marker = folium.CircleMarker(**marker_kwds)
514 else:
515 raise ValueError(
TypeError: __init__() missing 1 required positional argument: 'location'
https://colab.research.google.com/drive/1aJySwBvJvYDaAinDZwQ0R9riEqbtwqvn?usp=sharing
It seems the change to have location
to be a non-required keyword was done in https://github.com/python-visualization/folium/pull/957, which was merged a bit less than a year ago (which I think corresponds to 0.12.0, basically the last version).
There might of course be other issues, but it should be rather straightforward to add a location=None
when constructing those markers.
The minimum required by GeoPandas now is 0.12 (corresponding to NEP29 now). We can potentially check for that as a minimum version and raise an error if an older is installed but I am not sure how important that is now when 0.14 is the latest version.