Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gv.RGB does not work with NxMx3 arrays #522

Closed
TheoMathurin opened this issue Sep 10, 2021 · 0 comments · Fixed by #558
Closed

gv.RGB does not work with NxMx3 arrays #522

TheoMathurin opened this issue Sep 10, 2021 · 0 comments · Fixed by #558

Comments

@TheoMathurin
Copy link

TheoMathurin commented Sep 10, 2021

ALL software version info

Minimal example run with the following config, but encountered this issue in other environments:

  • geoviews 1.9.1
  • holoviews 1.14.5
  • bokeh 2.3.3
  • datashader 0.13.0
  • cartopy 0.18.0
  • python 3.9.7
  • jupyter and bokeh server
  • CentOS 7 / RHEL 7 / Ubuntu 18.04

Description of expected behavior and the observed behavior

In contrast to hv.RGB, gv.RGB only takes input arrays with shape NxMx4. Sending a NxMx3 array will raise an error at rendering, while the docstrings states that "[An] input array may have a shape of NxMx4 or NxMx3. In the latter case, the defined alpha dimension parameter is appended to the list of value dimensions."

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

import numpy as np
import geoviews as gv
import cartopy.crs as ccrs

gv.extension('bokeh')

img = np.array(np.zeros((100, 100, 3)))
coastline = gv.feature.coastline
rgb = gv.RGB(img, bounds=(-10, -10, 10, 10), crs=ccrs.PlateCarree()))

# When trying to render the following (in a notebook or bokeh server), an error will be issued
(rgb*coastline).opts(projection=ccrs.PlateCarree(), width=600, height=300)

Stack traceback and/or browser JavaScript console output

Last element of traceback:

~/miniconda3/envs/jupyter/lib/python3.9/site-packages/holoviews/core/data/image.py in values(cls, dataset, dim, expanded, flat, compute, keep_index)
    197             # than expanded column format, reorient before expanding
    198             if dataset.data.ndim > 2:
--> 199                 data = dataset.data[:, :, dim_idx-dataset.ndims]
    200             else:
    201                 data = dataset.data

IndexError: index 3 is out of bounds for axis 2 with size 3
@TheoMathurin TheoMathurin changed the title Issues with gv.RGB gv.RGB does not work with NxMx3 arrays Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant