Search code examples
geopandasholoviews

Choropleth map from Shape file in Holoviews


I have a shape file with a column named geometry containing MULTIPOLYGONs.

postcode    name    geometry
0   2003.0  A   MULTIPOLYGON Z (((1048559.000 7841160.000 0.00...
1   1438.0  B   MULTIPOLYGON Z (((-29156.720 6885495.170 0.000...

While it is straight forward to draw a map in matplotlib with GeoPandas, I can not get it to work in Holoviews. The example-script from Holoviews (http://holoviews.org/gallery/demos/bokeh/texas_choropleth_example.html) don't really solve the question of how to structure the data.

I have tried to read the shape file with GeoPandas without luck. What am I missing here? Do I need to decode the geometry column first?


Solution

  • If you install hvPlot, you should be able to plot shape columns directly from GeoPandas using HoloViews, as described at https://hvplot.holoviz.org/user_guide/Geographic_Data.html .

    import hvplot.pandas, geopandas as gpd
    
    world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
    world.hvplot(geo=True)
    

    enter image description here