Geoviews错误:“提供的数据不包含指定的维度”

2024-09-30 20:17:29 发布

您现在位置:Python中文网/ 问答频道 /正文

当我试图绘制Postgis Linestring时,由于gv.Path()hvplot(geo=True),我出现了以下错误:Supplied data does not contain specified dimensions, the following dimensions were not found: ['Longitude', 'Latitude']

sqla="Select Geography(ST_transform(traja,4326)) as traja, namea,nameb,mmsia,mmsib,p_dist,cpa_id from filtered where nm_a is not null and geometrytype(traja)='LINESTRING' limit 10"
gdf=gpd.read_postgis(sqla,con,geom_col='traja')
gdf.head()

gdf.head()

type(gdf['traja'][0])
----------------
shapely.geometry.linestring.LineString

当我尝试可视化时:

gdf.hvplot(geo=True)
----------------
DataError: Supplied data does not contain specified dimensions, the following dimensions were not found: ['Longitude', 'Latitude']

PandasInterface expects tabular data, for more information on supported datatypes see http://holoviews.org/user_guide/Tabular_Datasets.html

当我做hvplot(geo=False)时,它可以工作,但我希望有一个底图,并从Geoview的所有选项中受益。 有人有主意吗


Tags: thetruedatanotgeodimensionsfollowingspecified
1条回答
网友
1楼 · 发布于 2024-09-30 20:17:29

GeoViews需要知道哪些数据列或维度应用于纬度和经度。我认为您可以将数据列重命名为“经度”和“纬度”,或者您可以告诉GeoViews维度的名称,如gv.Path(data, ['lon','lat'])。可能也有一种方法可以将名称显式地提供给hvPlot,但我不确定如何做到这一点

相关问题 更多 >