holoviz / holoviz/hvplot

quadmesh does not work with both geo=True and multiple hover_cols.

Open
#1,089 0 comments 0 reactions 0 assignees View on GitHub
api: geo
Dominant language
Python
Stars
1.4k
Forks
124
Avg merge
1d 18h
Merged PRs (30d)
1

Description

#### ALL software version info
```
Python 3.10.11
bokeh 3.1.1
holoviews 1.16.2
hvplot 0.8.4
geoviews 1.10.0
panel 1.1.0
xarray 2023.5.0
```

#### Description of expected behavior and the observed behavior

With an xarray dataset, I would like to use hvplot quadmesh to overlay data on a geographic map using `geo=True` and display the data of multiple variables at once via a hover tool by passing those variables to the `hover_cols` argument in a list.

If I try to use both `geo=True` and multiple values in `hover_cols`, I get the `DataError` shown below.

#### Complete, minimal, self-contained example code that reproduces the issue

```
import geoviews as gv
import panel as pn
import xarray as xr
import hvplot.xarray

gv.extension('bokeh')

ds = xr.tutorial.open_dataset('air_temperature')
ds = ds.isel(time=0)
ds['variable2'] = ds['air'] * 2

qmesh = ds.hvplot.quadmesh(
x='lon',
y='lat',
z=['air', 'variable2'],
hover_cols=['air', 'variable2'],
geo=True,
)
qmesh = qmesh.opts(gv.opts.QuadMesh(colorbar=True, tools=['hover']))
plot = gv.tile_sources.CartoLight * qmesh
pn.pane.HoloViews(plot.opts(width=800, height=600)).servable()
```
This code works if you comment out either the `geo` arg or the `hover_cols` argument.

#### Stack traceback and/or browser JavaScript console output
```

File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/core/accessors.py", line 43, in pipelined_call
result = __call__(*args, **kwargs)
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/core/accessors.py", line 199, in __call__
new_obj = apply_function(self._obj, **inner_kwargs)
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/core/operation.py", line 214, in __call__
return self._apply(element)
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/core/operation.py", line 141, in _apply
ret = self._process(element, key)
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/geoviews/operation/projection.py", line 40, in _process
return element.map(self._process_element, self.supported_types)
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/core/data/__init__.py", line 199, in pipelined_fn
result = method_fn(*args, **kwargs)
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/core/data/__init__.py", line 1207, in map
return super().map(*args, **kwargs)
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/core/dimension.py", line 700, in map
return map_fn(self) if applies else self
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/geoviews/operation/projection.py", line 301, in _process_element
return element.clone((PX, PY, zs), crs=self.p.projection, **params)
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/geoviews/element/geo.py", line 118, in clone
return super().clone(data, shared_data, new_type,
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/core/data/__init__.py", line 1197, in clone
return super().clone(data, shared_data, new_type, *args, **overrides)
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/core/dimension.py", line 566, in clone
return clone_type(data, *args, **{k:v for k,v in settings.items()
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/geoviews/element/geo.py", line 111, in __init__
super().__init__(data, kdims=kdims, vdims=vdims, **kwargs)
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/element/raster.py", line 730, in __init__
super().__init__(data, kdims, vdims, **params)
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/element/selection.py", line 24, in __init__
super().__init__(*args, **kwargs)
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/core/data/__init__.py", line 331, in __init__
initialized = Interface.initialize(type(self), data, kdims, vdims,
File "/home/zgriffith/mambaforge/envs/panelv1/lib/python3.10/site-packages/holoviews/core/data/interface.py", line 268, in initialize
raise DataError(error)
holoviews.core.data.interface.DataError: None of the available storage backends were able to support the supplied data format.
```
#### Screenshots or screencasts of the bug in action
I tried dropping in with a debugger to see what the actual problem is [here](https://github.com/holoviz/holoviews/blob/main/holoviews/core/data/interface.py#L252):
```
ipdb> eltype

ipdb> type(data), len(data)
(, 3)
ipdb> kdims
[Dimension('lon', label='Longitude', unit='degrees_east'), Dimension('lat', label='Latitude', unit='degrees_north')]
ipdb> vdims
[Dimension('air', label='4xDaily Air temperature at sigma level 995', unit='degK'), Dimension('variable2', label='test', unit='test')]
ipdb> prioritized
[, ]
ipdb> prioritized[0].init(eltype, data, kdims, vdims)
*** KeyError: 'variable2'
ipdb> prioritized[1].init(eltype, data, kdims, vdims)
*** ValueError: Values for dimension variable2 not found
```
The `data` tuple is `(lat, lon, air)` - it seems like incorporating geoviews is dropping that extra data along the way.

related discourse discussion [here](https://discourse.holoviz.org/t/is-it-possible-to-display-additional-variables-under-a-quadmesh-hover-tool/5522)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.