error with `Canvas().raster` on xarray 0.17
See original GitHub issueALL software version info
The full list is available here, the gist is:
- Python 3.8
xarray
0.17.0datashader
0.12.0
Description of expected behavior and the observed behavior
I expect Canvas().raster
to return a DataArray
object, instead it returns an error.
Complete, minimal, self-contained example code that reproduces the issue
Adapted from your documentation
from datashader import transfer_functions as tf, reductions as rd
import numpy as np, datashader as ds, xarray as xr
def f(x,y):
return np.cos((x**2+y**2)**2)
def sample(fn, n=50, range_=(0.0,2.4)):
xs = ys = np.linspace(range_[0], range_[1], n)
x,y = np.meshgrid(xs, ys)
z = fn(x,y)
return xr.DataArray(z, coords=[('y',ys), ('x',xs)])
da = sample(f)
ds.Canvas().raster(da, interpolate='linear')
Stack traceback and/or browser JavaScript console output
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-7e8b8b432665> in <module>
12
13 da = sample(f)
---> 14 ds.Canvas().raster(da, interpolate='linear')
/opt/conda/lib/python3.8/site-packages/datashader/core.py in raster(self, source, layer, upsample_method, downsample_method, nan_value, agg, interpolate, chunksize, max_mem)
1131 dims = [ydim, xdim]
1132 attrs = dict(res=res[0])
-> 1133 if source._file_obj is not None and hasattr(source._file_obj, 'nodata'):
1134 attrs['nodata'] = source._file_obj.nodata
1135
/opt/conda/lib/python3.8/site-packages/xarray/core/common.py in __getattr__(self, name)
237 with suppress(KeyError):
238 return source[name]
--> 239 raise AttributeError(
240 "{!r} object has no attribute {!r}".format(type(self).__name__, name)
241 )
AttributeError: 'DataArray' object has no attribute '_file_obj'
I think this is related to #4809
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Releases — Datashader v0.14.3
Canvas.raster() now accepts xarray Dataset types, not just DataArrays, with the specific DataArray selectable from the Dataset using the column= argument of ...
Read more >Installation — xarray 0.17.1.dev0+g835a53e6.d20210226 ...
If you are using pip to install xarray, optional dependencies can be ... rasterio: for reading GeoTiffs and other gridded raster datasets.
Read more >RuntimeWarning when I try to plot a raster - GIS Stack Exchange
I'm be able to plot the source raster without problem: import geopandas as gpd import rioxarray as rxr from xarray.plot import imshow vector ......
Read more >Pakiety oprogramowania w gałęzi "bionic", Podsekcja python
... bpython3 (0.17.1-1) [universe]: fancy interface to the Python 3 interpreter ... python-bs4 (4.6.0-1): error-tolerant HTML parser for Python ...
Read more >Activity - QGIS Application - QGIS Issue Tracking
10:01 PM Bug report #17418 (Closed): UnicodeEncodeError when trying to create new layer with spatial index... I tried to upload a layer to...
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
This was always just a heuristic. I think we should support the major readers and conventions including
attrs['NODATA']
andattrs['nodatavals']
.This should be fixed in 0.12.1, which is available on the pyviz channel, conda-forge, and pip.