Geoview Labels grouped with points

Good morning. First post here, apologies if this has been solved elsewhere, my search came up empty.

As the title implies, I have grouped lat/lot points, selectable by drop down. I can see the values with a hover tool but would like the labels of the selected point group to be visible on the native plot. So far all of my attempts have failed, backend can’t support the format error.

I haven’t tried to plot labels in geoviews before, so maybe something basic I am missing. Looking for any advice on how to troubleshoot before I post code snippets. Thanks!


Hello John!

Here’s a basic geoviews example we can tinker with to try and get you troubleshooting:

import holoviews as hv
import geoviews as gv
import geoviews.tile_sources as gts
import pandas as pd
import geopandas
import panel as pn


df = pd.DataFrame(
                    {'City': ['Buenos Aires', 'Brasilia', 'Santiago', 'Bogota', 'Caracas','Tacna','Pucallpa','Lima','Langa'],
                    'Country': ['Argentina', 'Brazil', 'Chile', 'Colombia', 'Venezuela','Peru','Peru','Peru','Peru'],
                    'Latitude': [-34.58, -15.78, -33.45, 4.60, 10.48, -18.006,-8.392,-12.046,-12.125],
                    'Longitude': [-58.66, -47.91, -70.66, -74.08, -66.86,-70.246,-74.582,-77.0427,-76.4211]})       
gdf = geopandas.GeoDataFrame(df, geometry=geopandas.points_from_xy(df.Longitude, df.Latitude),crs="EPSG:3857")

gv_table = hv.Table(gdf)
checkbutton_group = pn.widgets.CheckButtonGroup(name='Check Button Group', value=['Points'], options=['Labels', 'Points'])

def full_plot(vis_list):
    base_plot = [tiles,]
    points = gv.Points(gv_table,kdims=['Longitude','Latitude'],vdims=['City','Country'])
    labels = gv.Labels(points,vdims=['City'])
    if 'Points' in vis_list:
    if 'Labels' in vis_list:
    return hv.Overlay(base_plot)

plot = hv.DynamicMap(full_plot)

layout = pn.Row(pn.Column(checkbutton_group,plot.opts(width=600,height=600)))

This should let you toggle on/off the point labels via the widget at the top:

… is this close to what you were aiming for? Instead of the widget you could trigger the label visibility of other things too, like selection streams, etc…

Thank you! I tried this in VS Code as a jupyter notebook, I can get the labels to show if I disable the conditional. For some reason, selecting Labels doesn’t feed back as I expect. Maybe an environment issue? Other geoviews groupby selections tend to work OK.

Really appreciate your assistance here. This is definite progress.