I’m running into this error which happens randomly after I work for sometime on a notebook in VsCode (it doesn’t seem to happen the first time I run the notebook, which makes it quite hard to debug…).
anomalies["SDU"].hvplot.image(
"lon",
"lat",
crs=ccrs.PlateCarree(),
features=dict(borders='50m'),
)
causes
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[85], line 1
----> 1 anomalies["SDU"].squeeze().hvplot.image(
2 "lon",
3 "lat",
4 crs=ccrs.PlateCarree(),
5 features=dict(coastline='50m', borders='50m'),
6 # width=800, # adjust width as needed
7 # height=600, # adjust height as needed
8 )
File ~/miniforge3/envs/default/lib/python3.12/site-packages/hvplot/plotting/core.py:2188, in hvPlot.image(self, x, y, z, colorbar, **kwds)
2134 def image(self, x=None, y=None, z=None, colorbar=True, **kwds):
2135 """
2136 Image plot
2137
(...) 2186 - Plotly: https://plotly.com/python/imshow/
2187 """
-> 2188 return self(x, y, z=z, kind='image', colorbar=colorbar, **kwds)
File ~/miniforge3/envs/default/lib/python3.12/site-packages/hvplot/plotting/core.py:95, in hvPlotBase.__call__(self, x, y, kind, **kwds)
92 plot = self._get_converter(x, y, kind, **kwds)(kind, x, y)
93 return pn.panel(plot, **panel_dict)
---> 95 return self._get_converter(x, y, kind, **kwds)(kind, x, y)
File ~/miniforge3/envs/default/lib/python3.12/site-packages/hvplot/converter.py:1917, in HoloViewsConverter.__call__(self, kind, x, y)
1914 obj = gv.project(obj, projection=self.output_projection)
1916 if not (self.datashade or self.rasterize or self.downsample):
-> 1917 layers = self._apply_layers(obj)
1918 layers = _transfer_opts_cur_backend(layers)
1919 return layers
File ~/miniforge3/envs/default/lib/python3.12/site-packages/hvplot/converter.py:2053, in HoloViewsConverter._apply_layers(self, obj)
2047 if feature_obj is None:
2048 raise ValueError(
2049 f'Feature {feature!r} was not recognized, must be one of '
2050 "'borders', 'coastline', 'lakes', 'land', 'ocean', "
2051 "'rivers' and 'states'."
2052 )
-> 2053 feature_obj = feature_obj.clone()
2054 if isinstance(self.features, dict):
2055 scale = self.features[feature]
File ~/miniforge3/envs/default/lib/python3.12/site-packages/geoviews/element/geo.py:158, in _Element.clone(self, data, shared_data, new_type, *args, **overrides)
156 if 'crs' not in overrides and (not new_type or isinstance(new_type, _Element)):
157 overrides['crs'] = self.crs
--> 158 return super().clone(data, shared_data, new_type,
159 *args, **overrides)
File ~/miniforge3/envs/default/lib/python3.12/site-packages/holoviews/core/dimension.py:563, in LabelledData.clone(self, data, shared_data, new_type, link, *args, **overrides)
561 # Apply name mangling for __ attribute
562 pos_args = getattr(self, '_' + type(self).__name__ + '__pos_params', [])
--> 563 return clone_type(data, *args, **{k:v for k,v in settings.items()
564 if k not in pos_args})
File ~/miniforge3/envs/default/lib/python3.12/site-packages/geoviews/element/geo.py:187, in Feature.__init__(self, data, kdims, vdims, **params)
185 if not isinstance(data, cFeature):
186 raise TypeError(f'{type(data).__name__} data has to be an cartopy Feature type')
--> 187 super().__init__(data, kdims=kdims, vdims=vdims, **params)
File ~/miniforge3/envs/default/lib/python3.12/site-packages/geoviews/element/geo.py:145, in _Element.__init__(self, data, kdims, vdims, **kwargs)
143 supplied_crs = kwargs.get('crs', None)
144 if supplied_crs and crs and crs != supplied_crs:
--> 145 raise ValueError('Supplied coordinate reference '
146 'system must match crs of the data.')
147 elif crs:
148 kwargs['crs'] = crs
ValueError: Supplied coordinate reference system must match crs of the data.
If I remove the line adding the borders then everything works fine. If I only try to add coastlines then everything works fine…
Anyone has any clue? Since the error is extremely weird I’m probably starting to think there is something wrong with my installation.