holoviz / holoviz/hvplot

xarray points plot give key error with geo=True

Open
#1,080 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
124
Avg merge
1d 18h
Merged PRs (30d)
1

Description

I have an xarray dataset with lon,lat, and would like to plot as points with `geo=True`.
Looks like others have hit this problem before: https://discourse.holoviz.org/t/mapping-irregular-point-measurements-with-xarray/1280/2

Here's a simple reproducer, which gives a key error on `lon` when a dataset is used, but works fine if converted to dataframe:
``` python
import numpy as np
import xarray as xr
import hvplot.xarray
import hvplot.pandas

ds = xr.Dataset({
'lat': ('trajectory', np.linspace(30, 35, 15)),
'lon': ('trajectory', np.linspace(16, 20, 15))
})
```
This doesn't work, giving: `KeyError: 'lon'`
``` python
ds.hvplot.points(x='lon', y='lat', geo=True, tiles='OSM')
```
But this *does* work:
``` python
ds.to_dataframe().hvplot.points(x='lon', y='lat', geo=True, tiles='OSM')
```

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.