在GeoViews中显示Linestrings的路径

3
我正在尝试使用Goeviews中的Path对象在Jupyter Notebook中可视化一些LINESTRINGS。该路径应根据交通量进行颜色编码(请参见下面的示例)。 我阅读了相关帖子Displaying Paths with Geoviews,给定的示例对我很有用。
但是,对于Linestrings,着色似乎不起作用。我错过了什么吗?非常感谢您的任何帮助!
import requests
import geopandas as gpd
import json

import holoviews as hv
import geoviews as gv
hv.extension('bokeh')

url = 'http://stadtplan.bonn.de/geojson?Thema=19584'
r = requests.get(url)
data = r.json()
gdf_traffic = gpd.GeoDataFrame.from_features(data['features'])
gdf_traffic.head(1)



#'geschwindigkeit' = 'traffic' in German
%%opts Path [width=500 height=500 color_index="geschwindigkeit"] (cmap='inferno')

gv.Path(gdf_traffic, vdims=["geschwindigkeit"])
2个回答

1
遇到类似的问题,我最终使用了 hvplot
gdf_traffic.set_geometry("geometry").hvplot(
    by = "geschwindigkeit",
    tiles = "CartoLight",
    legend_position = "top_left"
)

map result

在创建地理数据框之前,您需要导入`hvplot.pandas`模块。
我不确定为什么图例中缺少条目,还没有深入研究。也不确定如何更改颜色映射,似乎在HoloViz的GitHub上有相关的错误报告。

0
如果有人仍然想知道如何给LineStrings上色,这个方法对我有效:
gv.Path(gdf_traffic, vdims["geschwindigkeit"]).opts(opts.Path(color="yellow",line_width=2))

这将使所有的线条变为黄色,而不是根据geschwindigkeit来确定。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接