How do kdims work for polygons in geoviews?

耗尽温柔 提交于 2019-12-24 11:34:18

问题


I'm trying to understand how the kdims work for Polygon plots in geoviews. There is a similar question here but it hasn't really been answered - GeoViews: add a slider to chloropleth with Polygon geometries

In http://geo.holoviews.org/user_guide/Geometries.html the line

gv.Polygons(world, vdims='pop_est')

yields a world map with polygons shaded by population, and I think what it's somehow doing is getting lat/long as the kdims but I don't understand how this works. If I try to specify 'geometry' as the kdims I get an error "Expected two kdims to use GeoDataFrame, found 1."

My end goal is to be able specify the kdims so that I can also specify a "year" parameter as the kdims and get a scrollbar on the map.


回答1:


I think you are looking for something like (see also here: https://nbviewer.jupyter.org/github/poplarShift/pyviz-recipes/blob/master/notebooks/data_formats.ipynb)

import geoviews as gv
import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
import holoviews as hv
hv.extension('bokeh')

hv.Dataset(world, kdims=['Longitude', 'Latitude', 'continent'], vdims='pop_est').to(gv.Polygons)


来源:https://stackoverflow.com/questions/55680776/how-do-kdims-work-for-polygons-in-geoviews

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!