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.06k stars 103 forks source link

hvplot geopandas is broken #95

Closed ahuang11 closed 5 years ago

ahuang11 commented 5 years ago
import geopandas as gpd
import hvplot.pandas
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.hvplot(width=550) + world.hvplot(c='continent', width=500)
world
DataError                                 Traceback (most recent call last)
<ipython-input-6-7fc0479dbbb2> in <module>()
      2 import hvplot.pandas
      3 world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
----> 4 world.hvplot(width=550) + world.hvplot(c='continent', width=500)
      5 world

/mnt/c/Users/sephi/GOOGLE~1/Bash/hvplot/hvplot/__init__.py in __call__(self, x, y, kind, **kwds)
     88             self._data, x, y, kind=kind, **params
     89         )
---> 90         return converter(kind, x, y)
     91 
     92     def __dir__(self):

/mnt/c/Users/sephi/GOOGLE~1/Bash/hvplot/hvplot/converter.py in __call__(self, kind, x, y)
    515                 obj = DynamicMap(cbcallable, streams=[self.stream])
    516             else:
--> 517                 obj = method(x, y)
    518 
    519         if not (self.datashade or self.rasterize):

/mnt/c/Users/sephi/GOOGLE~1/Bash/hvplot/hvplot/converter.py in polygons(self, x, y, data)
   1028 
   1029     def polygons(self, x=None, y=None, data=None):
-> 1030         return self._geom_plot(x, y, data, kind='polygons')
   1031 
   1032     def paths(self, x=None, y=None, data=None):

/mnt/c/Users/sephi/GOOGLE~1/Bash/hvplot/hvplot/converter.py in _geom_plot(self, x, y, data, kind)
   1025         if self.geo: params['crs'] = self.crs
   1026         params['vdims'] = [c for c in data.columns if c != 'geometry']
-> 1027         return element(data, [x, y], **params).redim(**self._redim).redim.range(**ranges).opts(**opts)
   1028 
   1029     def polygons(self, x=None, y=None, data=None):

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/element/path.py in __init__(self, data, kdims, vdims, **params)
    149         else:
    150             params['vdims'] = vdims
--> 151         super(Contours, self).__init__(data, kdims=kdims, **params)
    152         if params.get('level') is not None:
    153             with disable_constant(self):

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/element/path.py in __init__(self, data, kdims, vdims, **params)
     57         elif isinstance(data, list) and all(isinstance(path, Path) for path in data):
     58             data = [p for path in data for p in path.data]
---> 59         super(Path, self).__init__(data, kdims=kdims, vdims=vdims, **params)
     60 
     61     def __setstate__(self, state):

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/core/data/__init__.py in __init__(self, data, kdims, vdims, **kwargs)
    216         validate_vdims = kwargs.pop('_validate_vdims', True)
    217         initialized = Interface.initialize(type(self), data, kdims, vdims,
--> 218                                            datatype=kwargs.get('datatype'))
    219         (data, self.interface, dims, extra_kws) = initialized
    220         super(Dataset, self).__init__(data, **dict(kwargs, **dict(dims, **extra_kws)))

/mnt/c/Users/sephi/GOOGLE~1/Bash/holoviews/holoviews/core/data/interface.py in initialize(cls, eltype, data, kdims, vdims, datatype)
    249                                   % (intfc.__name__, e))
    250                 error = ' '.join([error, priority_error])
--> 251             raise DataError(error)
    252 
    253         return data, interface, dims, extra_kws

DataError: None of the available storage backends were able to support the supplied data format.
philippjfr commented 5 years ago

Works for me, could you report your versions?

ColinTalbert commented 5 years ago

I get the same error. Windows 10,

print("gbd", gpd.__version__)
print("hvplot", hvplot.__version__)

gbd 0.4.0
hvplot 0.2.1
ahuang11 commented 5 years ago

Also Windows 10 Subsystem Linux: hvplot 0.2.1.post5+gcba25ba.dirty gpd 0.4.0

philippjfr commented 5 years ago

Thank you both, I was still on geopandas 0.3.0, which does work. Will probably need to make some updates in geoviews.

philippjfr commented 5 years ago

Figured out the issue, nothing to with versions. Simply have to make sure that geoviews is imported, otherwise the geopandas interface isn't loaded and it simply won't understand the data.

I'll make a PR on hvplot which does the import for you.