Open jlstevens opened 6 years ago
The workaround I have found is as follows:
data.to_dataset(name='data')[['x','y', 'data']]
Using to_dataset
to promote the array to a datset is fine, but having to set the ordering is rather annoying!
I believe the ordering/naming issue has been discussed extensively somewhere, but I can't find it anywhere to link it in here. Maybe @philippjfr remembers.
One last comment: it is probably best to solve this at the holoviews level even though this particular problem manifests itself most obviously at the geoviews leve.
Given a DataArray called
data
that looks like this:I get the following traceback if I try
gv.Image(data, crs=ccrs.epsg(32611))
:This happens whether or not I drop the irrelevant ``band`` dimension (as you might expect) but it does work correctly once expressed as a ``Dataset`` instead. It seems to me that we ought to be able to promote ``DataArray``s to ``DataSet``s that have a single data variable as all the necessary information is available from the ``DataArray`` (except for the name of the data variables which should match our default of 'z'). That way you can have a data array promoted to a dataset which you could redim from the 'z' default to give it a suitable name for the data variable. Of course if you specify a vdim that isn't 'z' and supply a ``DataArray``, you would get the usual error about data missing for the requested vdim. One motivation to support ``DataArray`` is that this is the format returned by ``xr.open_rasterio(f)`` for file ``f``.