holoviz / hvplot

A high-level plotting API for pandas, dask, xarray, and networkx built on HoloViews
https://hvplot.holoviz.org
BSD 3-Clause "New" or "Revised" License
1.08k stars 105 forks source link

Unable to plot geographic tiles #744

Open cdeciampa opened 2 years ago

cdeciampa commented 2 years ago

I'm working with weather modeling data in xarray and I'm able to plot just fine without geographic tiles:

Screen Shot 2022-04-28 at 3 11 48 PM

but hvplot fails with the exact same command when geo=True:

WARNING:param.dynamic_operation: Callable raised "ValueError('assignment destination is read-only')".
Invoked as dynamic_operation(cftime.DatetimeNoLeap(2018, 9, 11, 0, 0, 0, 0, has_year_zero=True), 124.50591878125051)
Unexpected exception formatting exception. Falling back to standard exception
Traceback (most recent call last):
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/IPython/core/formatters.py", line 222, in catch_format_error
    r = method(self, *args, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/IPython/core/formatters.py", line 973, in __call__
    return method(include=include, exclude=exclude)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/dimension.py", line 1316, in _repr_mimebundle_
    return Store.render(self)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/options.py", line 1405, in render
    ret = hook(obj)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/ipython/display_hooks.py", line 282, in pprint_display
    return display(obj, raw_output=True)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/ipython/display_hooks.py", line 258, in display
    output = map_display(obj)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/ipython/display_hooks.py", line 146, in wrapped
    mimebundle = fn(element, max_frames=max_frames)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/ipython/display_hooks.py", line 206, in map_display
    return render(vmap)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/ipython/display_hooks.py", line 68, in render
    return renderer.components(obj, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/plotting/renderer.py", line 410, in components
    model = plot.layout._render_model(doc, comm)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/panel/viewable.py", line 460, in _render_model
    model = self.get_root(doc, comm)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/panel/viewable.py", line 518, in get_root
    root = self._get_model(doc, comm=comm)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/panel/layout/base.py", line 122, in _get_model
    objects = self._get_objects(model, [], doc, root, comm)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/panel/layout/base.py", line 112, in _get_objects
    child = pane._get_model(doc, root, model, comm)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/panel/pane/holoviews.py", line 248, in _get_model
    plot = self._render(doc, comm, root)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/panel/pane/holoviews.py", line 321, in _render
    return renderer.get_plot(self.object, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/plotting/bokeh/renderer.py", line 73, in get_plot
    plot = super(BokehRenderer, self_or_cls).get_plot(obj, doc, renderer, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/plotting/renderer.py", line 220, in get_plot
    initialize_dynamic(obj)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/plotting/util.py", line 254, in initialize_dynamic
    dmap[dmap._initial_key()]
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1344, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1111, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/spaces.py", line 708, in __call__
    ret = self.callable(*args, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1044, in dynamic_operation
    return apply(obj, *key, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1036, in apply
    processed = self._process(element, key, kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1020, in _process
    return self.p.operation(element, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/hvplot/converter.py", line 1089, in method_wrapper
    el = method(x, y, data=ds.data)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/hvplot/converter.py", line 1929, in contour
    qmesh = project(qmesh, projection=projection)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/param/parameterized.py", line 3652, in __new__
    return inst.__call__(*args,**params)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/operation.py", line 220, in __call__
    return element.apply(self, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/accessors.py", line 47, in pipelined_call
    result = __call__(*args, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/accessors.py", line 204, in __call__
    new_obj = apply_function(self._obj, **inner_kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/operation.py", line 214, in __call__
    return self._apply(element)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/operation.py", line 141, in _apply
    ret = self._process(element, key)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/geoviews/operation/projection.py", line 439, in _process
    element = element.map(op.instance(projection=self.p.projection),
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/data/__init__.py", line 207, in pipelined_fn
    result = method_fn(*args, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/data/__init__.py", line 1223, in map
    return super(Dataset, self).map(*args, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/dimension.py", line 710, in map
    return map_fn(self) if applies else self
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/operation.py", line 220, in __call__
    return element.apply(self, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/accessors.py", line 47, in pipelined_call
    result = __call__(*args, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/accessors.py", line 204, in __call__
    new_obj = apply_function(self._obj, **inner_kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/operation.py", line 214, in __call__
    return self._apply(element)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/operation.py", line 141, in _apply
    ret = self._process(element, key)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/geoviews/operation/projection.py", line 40, in _process
    return element.map(self._process_element, self.supported_types)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/data/__init__.py", line 207, in pipelined_fn
    result = method_fn(*args, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/data/__init__.py", line 1223, in map
    return super(Dataset, self).map(*args, **kwargs)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/dimension.py", line 710, in map
    return map_fn(self) if applies else self
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/geoviews/operation/projection.py", line 289, in _process_element
    zs[mask] = np.NaN
ValueError: assignment destination is read-only

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 1982, in showtraceback
    stb = self.InteractiveTB.structured_traceback(
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1118, in structured_traceback
    return FormattedTB.structured_traceback(
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/IPython/core/ultratb.py", line 1012, in structured_traceback
    return VerboseTB.structured_traceback(
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/IPython/core/ultratb.py", line 865, in structured_traceback
    formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/IPython/core/ultratb.py", line 818, in format_exception_as_a_whole
    frames.append(self.format_record(r))
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/IPython/core/ultratb.py", line 736, in format_record
    result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/stack_data/core.py", line 698, in lines
    pieces = self.included_pieces
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/stack_data/core.py", line 645, in included_pieces
    scope_pieces = self.scope_pieces
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/stack_data/core.py", line 585, in scope_pieces
    for piece in self.source.pieces
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/stack_data/utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/stack_data/core.py", line 90, in pieces
    return list(self._clean_pieces())
  File "/Users/cnd5285/opt/anaconda3/envs/hvplot/lib/python3.10/site-packages/stack_data/core.py", line 114, in _clean_pieces
    raise AssertionError("Pieces mismatches: %s" % mismatches)
AssertionError: Pieces mismatches: [{681, 682}, {696, 697}, {709, 710}, {715, 716}]
Out[24]:
:DynamicMap   [time,lev]
maximlt commented 2 years ago

@cdeciampa I'd be great if you could provide a minimal example for us to reproduce that bug (uploading an example input file if required?).

openSourcerer9000 commented 1 year ago

I was getting an almost identical error, I was getting an example together to post here when I realized I was actually passing a random, unrelated object into the height kwarg. I had defined w,h = 1800,1200 earlier, and had been using gdf.hvplot(...,width=w,height=h), but at some point I had redefined h as a class object! Fixing that worked, I would recommend validating the type of the plot kwargs as they come in, since this error made it 9 levels upstream it makes for tricky debugging.