Hover over a GeoPandas line feature highlights single segment, not the whole line

In a holoview (or geoviews / hvplot) plot of a GeoPandas line GeoDataFrame, when hovering over one of the line features, I’d like to highlight (using hover_line_color) the entire line feature. Instead, only the individual line segment is highlighted. I haven’t found a way to highlight the entire line feature, or documentation that says that’s not possible.

Here’s a Jupyter notebook in a gist that demonstrates this. Note that while the example uses hvplot on a GeoDataFrame, the same behavior is observed after converting from the GeoPandas GeoDataFrame to a geoviews Path or a Spatialpandas GeoDataFrame, or when removing geo=True.

In contrast, a polygon GeoDataFrame feature behaves as expected: the entire polygon is highlighted when hovering over it.


Does anyone have insight on this behavior? Another way of framing this is: how can holoviews or geoviews handle an individual Path feature (containing multiple line segments) as a single unit, for line highlighting during hover among other things?

This behavior works as expected for polygons and – naturally – points, but not for lines / paths.

I’ve tried it on different versions of holoviews & hvplot, with the same result.


What if you convert it to MultiLineString?

Thanks for the suggestion! In principle, LineString should work, since it’s defined as containing one or more (connected) segments. A MultiLineString is a collection of disconnected LineString features.

I tweaked the gist I shared to use MultiLineString instead of LineString. The behavior didn’t change, though; individual segments are still highlighted.

Here’s what I changed:

geojson_features = [
    {"type": "Feature", 
     "properties": {"id": 19}, 
     "geometry": {"type": "MultiLineString", "coordinates": [[[140.51, 4.40], [140.59, 4.33], [140.62, 4.29]]]}
    {"type": "Feature", 
     "properties": {"id": 20}, 
     "geometry": {"type": "MultiLineString", "coordinates": [[[140.61, 4.39], [140.65, 4.37], [140.69, 4.33]]]}

Right, I meant combining those two features (so there’s only id: 19) into a MultiLineString.

Oh I see the issue now. There are two segments of 19.

Can you report this as a bug on GeoViews?

I can do that. But would this be a Geoviews or Holoviews issue? In the gist I shared, I used geo=True in the hvplot command. But I get the same behavior without it, with just holoviews.

1 Like

HoloViews then. Thanks!

Will do.

Done. Hover over a GeoPandas line feature highlights single segment, not the whole line · Issue #5949 · holoviz/holoviews · GitHub

1 Like