How to use the hvplot.util.is_geopandas function in hvplot

To help you get started, we’ve selected a few hvplot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holoviz / hvplot / hvplot / converter.py View on Github external
self.data_source = data
        self.is_series = is_series(data)
        if self.is_series:
            data = data.to_frame()
        if is_intake(data):
            data = process_intake(data, use_dask or persist)

        if groupby is not None and not isinstance(groupby, list):
            groupby = [groupby]
        if by is not None and not isinstance(by, list):
            by = [by]
        grid = []
        if row is not None: grid.append(row)
        if col is not None: grid.append(col)
        streaming = False
        if is_geopandas(data):
            datatype = 'geopandas'
            self.data = data
            if kind is None:
                geom_types = set([gt[5:] if 'Multi' in gt else gt for gt in data.geom_type])
                if len(geom_types) > 1:
                    raise ValueError('The GeopandasInterface can only read dataframes which '
                                     'share a common geometry type')
                geom_type = list(geom_types)[0]
                if geom_type == 'Point':
                    kind = 'points'
                elif geom_type == 'Polygon':
                    kind = 'polygons'
                elif geom_type in ('LineString', 'LineRing'):
                    kind = 'paths'
        elif isinstance(data, pd.DataFrame):
            datatype = 'pandas'
github holoviz / hvplot / hvplot / converter.py View on Github external
def _geom_plot(self, x=None, y=None, data=None, kind='polygons'):
        data, x, y, _ = self._process_gridded_args(data, x, y, z=None)
        params = dict(self._relabel)

        if not (x and y):
            if is_geopandas(data):
                x, y = ('Longitude', 'Latitude') if self.geo else ('x', 'y')
            elif self.gridded_data:
                x, y = self.variables[:2:-1]
            else:
                x, y = data.columns[:2]

        opts = dict(plot=self._plot_opts, style=self._style_opts, norm=self._norm_opts)
        redim = self._merge_redim({self._color_dim: self._dim_ranges['c']} if self._color_dim else {})
        kdims, vdims = self._get_dimensions([x, y], [])
        element = self._get_element(kind)
        if self.geo: params['crs'] = self.crs
        if self.by:
            obj = Dataset(data).to(element, kdims, vdims, self.by, **params).overlay()
        else:
            obj = element(data, kdims, vdims, **params)