我正在尝试使用 Geopandas 及其在 Colab 中的 explore() 方法绘制交互式 map 。
但是,当我写时:
my_geodataframe.explore()
出现以下错误:
TypeError Traceback (most recent call last)
<ipython-input-11-e71fb33b059f> in <module>()
----> 1 mapa_interactivo = mapa1.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'
我明确写下了位置:
my_geodataframe.explore(location=[40.463667, -3.74922])
但错误仍然存在。
我正在创建显示西类牙每个省的失业率的 map 。地理数据可以从以下来源下载:
http://centrodedescargas.cnig.es/CentroDescargas/buscar.do?filtro.codFamilia=LILIM&filtro.codCA=11#
各省的失业率数据可以从这个下载:
https://www.ine.es/jaxiT3/Datos.htm?t=3996
将信息合并到一个独特的地理数据框中后,我得到如下结果:
我已经能够毫无问题地绘制静态分区统计图:
您可以在以下链接中找到我用来绘制它的代码:
如上所述,问题是在尝试绘制交互式 map 时出现的。
有什么建议吗?
最佳答案
geopandas.GeoDataFrame.explore
的第一个位置参数是列
:
column: str, np.array, pd.Series (default None)
The name of the dataframe column, numpy.array, or pandas.Series to be plotted. If numpy.array or pandas.Series are used then it must have same length as dataframe.
如果您要绘制包含多个列的数据框,请务必提供您想要探索的列的名称,如下所示:
my_geodataframe.explore('Tasa_Paro')
关于python - Geodataframe.explore()错误: __init__() missing 1 required positional argument: 'location' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71239094/