【问题标题】:Geoviews error : "Supplied data does not contain specified dimensions"Geoviews 错误:“提供的数据不包含指定的维度”
【发布时间】:2021-12-02 21:43:09
【问题描述】:

当我尝试绘制 Postgis 线串时,感谢 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()

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 的所有选项中受益。 有人有想法吗?

【问题讨论】:

标签: python postgis geopandas holoviews geoviews


【解决方案1】:

GeoViews 需要知道您的哪些数据列或维度应该用于纬度和经度。我认为您可以将数据列重命名为“经度”和“纬度”,或者您可以使用 gv.Path(data, ['lon','lat']) 之类的名称告诉 GeoViews 维度的名称。可能还有一种方法可以将名称明确地提供给 hvPlot,但我不知道该怎么做。

【讨论】:

  • 感谢您的回答,但我要绘制的数据包含在一列中,因为它是 Postgis“线串”几何,正如您在屏幕截图中看到的那样。
  • 在这种情况下,您可能需要将 PostGIS 几何图形转换为 GeoViews 支持的 Shapely 几何图形?见shapely.readthedocs.io/en/stable/manual.html#interoperation,例如geom = shapely.wkb.loads(hex_geom[0], hex=True)
  • 一定是这样!我会尽力与您保持联系
  • 我编辑了帖子以使其更清晰。不幸的是,我的对象似乎已经是 Shapely 几何图形,正如您在 type() 行中看到的那样
  • 看起来 GeoViews 目前需要将几何列命名为“geometry”,所以我尝试将 traja 重命名为 geometry
猜你喜欢
  • 1970-01-01
  • 2015-03-13
  • 1970-01-01
  • 2021-08-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多