Support lon/lat bounds in QuadMesh
See original GitHub issuepcolormesh
will work correctly for 2D data with bounds according to the definition.
I tested the Dataset below:
<xarray.Dataset>
Dimensions: (y_bounds: 4173, x_bounds: 451, y: 4172, x: 450)
Coordinates:
lon_bounds (y_bounds, x_bounds) float32 dask.array<chunksize=(4096, 451), meta=np.ndarray>
lat_bounds (y_bounds, x_bounds) float32 dask.array<chunksize=(4096, 451), meta=np.ndarray>
time datetime64[ns] 2019-08-10
latitude (y, x) float32 dask.array<chunksize=(4096, 450), meta=np.ndarray>
longitude (y, x) float32 dask.array<chunksize=(4096, 450), meta=np.ndarray>
crs object +proj=latlong +datum=WGS84 +e...
Dimensions without coordinates: y_bounds, x_bounds, y, x
Data variables:
nitrogendioxide_tropospheric_column (y, x) float32 dask.array<chunksize=(4096, 450), meta=np.ndarray>
import geoviews as gv
gvds = gv.Dataset(ds.unify_chunks()).persist()
mesh = gvds.to(gv.QuadMesh,
kdims=["lon_bounds", "lat_bounds"],
vdims=['nitrogendioxide_tropospheric_column'])
Here’s the error:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/tmp/ipykernel_163767/1539571452.py in <module>
2 gvds = gv.Dataset(ds.unify_chunks()).persist()
3
----> 4 mesh = gvds.to(gv.QuadMesh,
5 kdims=["lon_bounds", "lat_bounds"],
6 vdims=['nitrogendioxide_tropospheric_column'])
~/new/miniconda3/envs/arctic/lib/python3.8/site-packages/geoviews/element/__init__.py in __call__(self, *args, **kwargs)
37 args = (Dataset,)
38 kwargs['kdims'] = []
---> 39 converted = super(GeoConversion, self).__call__(*args, **kwargs)
40 if is_gpd:
41 if kdims is None: kdims = group_type.kdims
~/new/miniconda3/envs/arctic/lib/python3.8/site-packages/holoviews/core/data/__init__.py in __call__(self, new_type, kdims, vdims, groupby, sort, **kwargs)
142 else:
143 selected = self._element.reindex(groupby+kdims, vdims)
--> 144 params = {'kdims': [selected.get_dimension(kd, strict=True) for kd in kdims],
145 'vdims': [selected.get_dimension(vd, strict=True) for vd in vdims],
146 'label': selected.label}
~/new/miniconda3/envs/arctic/lib/python3.8/site-packages/holoviews/core/data/__init__.py in <listcomp>(.0)
142 else:
143 selected = self._element.reindex(groupby+kdims, vdims)
--> 144 params = {'kdims': [selected.get_dimension(kd, strict=True) for kd in kdims],
145 'vdims': [selected.get_dimension(vd, strict=True) for vd in vdims],
146 'label': selected.label}
~/new/miniconda3/envs/arctic/lib/python3.8/site-packages/holoviews/core/dimension.py in get_dimension(self, dimension, default, strict)
987 name_map.update({util.dimension_sanitizer(dim.name): dim for dim in all_dims})
988 if strict and dimension not in name_map:
--> 989 raise KeyError("Dimension %r not found." % dimension)
990 else:
991 return name_map.get(dimension, default)
KeyError: "Dimension 'lon_bounds' not found."
So, I suppose we can’t use bounds at this stage?
Note that if we don’t use bounds for pcolormesh
, it will produce strange stripes over the polar region like this:
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How do I plot an irregularly gridded RGB using holoview ...
I am working with irregularly gridded earth observation data, and am trying to find ways to plot this efficiently using holoview with bokeh ......
Read more >Gridded Datasets — HoloViews v1.15.3
HoloViews provides many different elements supporting regularly spaced rectilinear grids, but currently only QuadMesh supports irregularly spaced ...
Read more >Plotting — xarray 0.7.1 documentation
Not all xarray plotting methods support passing positional arguments to the ... color bar indicate that the colors include data points outside the...
Read more >Plotting - Xarray
The data model of xarray does not support datasets with cell boundaries yet. If you want to use these coordinates, you'll have to...
Read more >Gridded Datasets - | notebook.community
HoloViews provides many different elements supporting regularly spaced rectilinear grids, but currently only QuadMesh supports irregularly spaced ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great thanks @zxdawn for reporting how to do that correctly 😃
@maximlt You’re welcome. I found another problem of setting the extent of the project and posted it on the forum. If that’s actually an issue, I can submit it on GitHub. Otherwise, if that’s a usage topic, I will keep it there.