1

我正在尝试使用地理视图来显示路径。我可以让它只正确显示点:

import numpy as np
import geoviews as gv
import cartopy.crs as ccrs
import pandas as pd

hv.extension('bokeh')

coord_system = ccrs.UTM(17)

userLine = [[ 501386.89237725, 3026047.23276743],
 [ 502233.40219658, 3030363.86891928],
 [ 497065.22714886, 3031309.6654351 ],
 [ 499260.08171301, 3027147.9437062 ],
 [ 494678.08475863, 3026891.08691589],
 [ 494971.32963864, 3025188.1383645 ],
 [ 496475.86909916, 3025394.03293946],
 [ 496061.07730504, 3026116.58492655],
 [ 497530.90995815, 3026357.00292598]]

line_pd = pd.DataFrame(userLine, columns=['Longitude', 'Latitude'])
pressure = pd.DataFrame(np.arange(0,401,np.ceil(401/len(userLine))), columns=['Pressure'])
windspeed = pd.DataFrame(np.arange(0,201,np.ceil(201/len(userLine))), columns=['Max_Wind_Speed'])
alldata = pd.concat([line_pd,pressure,windspeed], axis=1)

gvdata = gv.Dataset(alldata, kdims=['Pressure','Max_Wind_Speed','Longitude','Latitude'])
hover = HoverTool(tooltips=[("Longitude", "@Longitude"), ("Latitude", "@Latitude"), ("Pressure","@Pressure"),("Max Wind Speed","@Max_Wind_Speed")])

%%opts Points (size=10 cmap='inferno') [tools=[hover] color_index=4]
gvdata.to(gv.Points, kdims=['Longitude', 'Latitude'], vdims=['Pressure','Max_Wind_Speed'], crs=coord_system)

但我真正想要的是一条道路。但是,当我尝试:

gvdata.to(gv.Path, kdims=['Longitude', 'Latitude'], crs=coord_system)

我收到错误消息DataError: None of the available storage backends were able to support the supplied data format.

我尝试重新格式化输入数据,但没有成功。我不确定我还能做错什么。

4

1 回答 1

3

.to方法的目的是让您轻松地对高维数据进行分组。在此特定示例中,您只有两个维度(纬度和经度),因此无需使用.to. 在您的特定示例中,这应该足以构建绘图:

gv.Path([userLine], crs=coord_system)

PathHoloViews 中的类型可以使用数组列表、数据框或列字典来构造,因此这也可以:

line_pd = pd.DataFrame(userLine, columns=['Longitude', 'Latitude'])
gv.Path([line_pd], crs=coord_system)

编辑:在您的扩展示例中,适用于我的格式如下:

%%opts Path (cmap='inferno') [tools=[hover] color_index='Max_Wind_Speed']
gv.Path([alldata], vdims=['Pressure','Max_Wind_Speed'], crs=coord_system)
于 2018-03-09T17:09:09.460 回答