GeoViews: add a slider to chloropleth with Polygon geometriesGeoviews: Add a slider to choropleth mapHow do kdims work for polygons in geoviews?Getting counts of intersections between geometries in GeoPandasAdding Legend to Chloropleth map in GeoPandasMake a union of polygons in GeoPandas, or Shapely (into a single geometry)Compare geometries with geopandasBokeh Geoviews use Lat/Long or UTM?Retrieving geometry in GeoPandas dataframe as json [Edit: use .to_json()]Geoviews: Add a slider to choropleth mapGeoviews + Datashader is slow when projecting pointsadd labels to polygonscount number of polygons with same geometry in single dataframe

Do I care if the housing market has gone up or down, if I'm moving from one house to another?

Can a ring have no zero divisors while being non-commutative and having no unity?

Calculating Fibonacci sequence in several different ways

What is the right way to verify an off-chain transaction with golang?

Why can't a country print its own money to spend it only abroad?

How to pass array of values in lualatex?

Found more old paper shares from broken up companies

I am a dual citizen of United States and Mexico, can I use my Mexican license in california when visiting?

Why does the salt in the oceans not sink to the bottom?

Longest to Shortest tractates of Yerushalmi by daf

Why Lie algebras if what we care about in physics are groups?

"Bootstrapping" an unbounded class of inaccessible cardinals

Can "Taking algebraic closure" be made into a functor?

Did Don Young threaten John Boehner with a 10 inch blade to the throat?

Function pointer parameter without asterisk

What do Unicorns want?

What does the following chess proverb mean: "Chess is a sea where a gnat may drink from and an elephant may bathe in."

Killing a star safely

Why was Quirrell said to be in the Black Forest if Voldemort was actually in Albania?

Is it better to deliver many low-value stories or few high-value stories?

Acoustic guitar chords' positions vs those of a Bass guitar

How to use AppendTo in a While loop?

Host telling me to cancel my booking in exchange for a discount?

Do I have to mention my main character's age?



GeoViews: add a slider to chloropleth with Polygon geometries


Geoviews: Add a slider to choropleth mapHow do kdims work for polygons in geoviews?Getting counts of intersections between geometries in GeoPandasAdding Legend to Chloropleth map in GeoPandasMake a union of polygons in GeoPandas, or Shapely (into a single geometry)Compare geometries with geopandasBokeh Geoviews use Lat/Long or UTM?Retrieving geometry in GeoPandas dataframe as json [Edit: use .to_json()]Geoviews: Add a slider to choropleth mapGeoviews + Datashader is slow when projecting pointsadd labels to polygonscount number of polygons with same geometry in single dataframe






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to do something similar to the OP in this question Geoviews: Add a slider to choropleth map, but it wasn't fully answered. In brief, I have a GeoDataFrame like this:



GeoDataFrame with Polygon geometries



I would like to visualise pre_anom by geometry in a GeoViews map, but I have multiple years for each geometry element. I'd like to have a slider created automatically for the extra kdim year, but if I specify year as a kdim like so:



gv.Polygons(gdf, kdims=['year'], vdims=['pre_anom']).opts(width=600, height=600, 
tools=['hover'], colorbar=True,
cmap='RdBu', color_index='pre_anom',
symmetric=True, toolbar='above',
line_color='white')


I get the following error:



---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-78-0358d9976c72> in <module>
----> 1 gv.Polygons(gdf, kdims=['year'], vdims=['pre_anom']).opts(width=600, height=600, tools=['hover'],
2 colorbar=True, cmap='RdBu', color_index='pre_anom',
3 symmetric=True, toolbar='above', line_color='white')

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/geoviews/element/geo.py in __init__(self, data, kdims, vdims, **kwargs)
98 elif isinstance(data, _Element):
99 kwargs['crs'] = data.crs
--> 100 super(_Element, self).__init__(data, kdims=kdims, vdims=vdims, **kwargs)
101
102

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/element/path.py in __init__(self, data, kdims, vdims, **params)
217 else:
218 params['vdims'] = vdims
--> 219 super(Contours, self).__init__(data, kdims=kdims, **params)
220 if params.get('level') is not None:
221 with disable_constant(self):

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/element/path.py in __init__(self, data, kdims, vdims, **params)
90
91 super(Path, self).__init__(data, kdims=kdims, vdims=vdims,
---> 92 datatype=datatype, **params)
93
94

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/core/data/__init__.py in __init__(self, data, kdims, vdims, **kwargs)
210 datatype=kwargs.get('datatype'))
211 (data, self.interface, dims, extra_kws) = initialized
--> 212 super(Dataset, self).__init__(data, **dict(kwargs, **dict(dims, **extra_kws)))
213 self.interface.validate(self, validate_vdims)
214

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/core/dimension.py in __init__(self, data, kdims, vdims, **params)
994 params['cdims'] = d if isinstance(d, Dimension) else Dimension(d): val
995 for d, val in params['cdims'].items()
--> 996 super(Dimensioned, self).__init__(data, **params)
997 self.ndims = len(self.kdims)
998 cdims = [(d.name, val) for d, val in self.cdims.items()]

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/core/dimension.py in __init__(self, data, id, plot_id, **params)
650 params['group'] = long_name
651
--> 652 super(LabelledData, self).__init__(**params)
653 if not util.group_sanitizer.allowable(self.group):
654 raise ValueError("Supplied group %r contains invalid characters." %

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/parameterized.py in __init__(self, **params)
2029 self.param._generate_name()
2030
-> 2031 self.param._setup_params(**params)
2032 object_count += 1
2033

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/parameterized.py in override_initialization(self_, *args, **kw)
808 original_initialized=parameterized_instance.initialized
809 parameterized_instance.initialized=False
--> 810 fn(parameterized_instance,*args,**kw)
811 parameterized_instance.initialized=original_initialized
812 return override_initialization

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/parameterized.py in _setup_params(self_, **params)
950 self.param.warning("Setting non-parameter attribute %s=%s using a mechanism intended only for parameters",name,val)
951 # i.e. if not desc it's setting an attribute in __dict__, not a Parameter
--> 952 setattr(self,name,val)
953
954 @classmethod

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/__init__.py in __set__(self, obj, val)
1217 def __set__(self,obj,val):
1218 """Set to the given value, raising an exception if out of bounds."""
-> 1219 self._check_bounds(val)
1220 super(List,self).__set__(obj,val)
1221

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/__init__.py in _check_bounds(self, val)
1236 if min_length is not None and max_length is not None:
1237 if not (min_length <= l <= max_length):
-> 1238 raise ValueError("%s: list length must be between %s and %s (inclusive)"%(self._attrib_name,min_length,max_length))
1239 elif min_length is not None:
1240 if not min_length <= l:

ValueError: kdims: list length must be between 2 and 2 (inclusive)









share|improve this question






















  • See my answer here: stackoverflow.com/a/55731617/10310883 for you one-liner

    – doppler
    Apr 17 at 15:55

















0















I am trying to do something similar to the OP in this question Geoviews: Add a slider to choropleth map, but it wasn't fully answered. In brief, I have a GeoDataFrame like this:



GeoDataFrame with Polygon geometries



I would like to visualise pre_anom by geometry in a GeoViews map, but I have multiple years for each geometry element. I'd like to have a slider created automatically for the extra kdim year, but if I specify year as a kdim like so:



gv.Polygons(gdf, kdims=['year'], vdims=['pre_anom']).opts(width=600, height=600, 
tools=['hover'], colorbar=True,
cmap='RdBu', color_index='pre_anom',
symmetric=True, toolbar='above',
line_color='white')


I get the following error:



---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-78-0358d9976c72> in <module>
----> 1 gv.Polygons(gdf, kdims=['year'], vdims=['pre_anom']).opts(width=600, height=600, tools=['hover'],
2 colorbar=True, cmap='RdBu', color_index='pre_anom',
3 symmetric=True, toolbar='above', line_color='white')

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/geoviews/element/geo.py in __init__(self, data, kdims, vdims, **kwargs)
98 elif isinstance(data, _Element):
99 kwargs['crs'] = data.crs
--> 100 super(_Element, self).__init__(data, kdims=kdims, vdims=vdims, **kwargs)
101
102

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/element/path.py in __init__(self, data, kdims, vdims, **params)
217 else:
218 params['vdims'] = vdims
--> 219 super(Contours, self).__init__(data, kdims=kdims, **params)
220 if params.get('level') is not None:
221 with disable_constant(self):

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/element/path.py in __init__(self, data, kdims, vdims, **params)
90
91 super(Path, self).__init__(data, kdims=kdims, vdims=vdims,
---> 92 datatype=datatype, **params)
93
94

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/core/data/__init__.py in __init__(self, data, kdims, vdims, **kwargs)
210 datatype=kwargs.get('datatype'))
211 (data, self.interface, dims, extra_kws) = initialized
--> 212 super(Dataset, self).__init__(data, **dict(kwargs, **dict(dims, **extra_kws)))
213 self.interface.validate(self, validate_vdims)
214

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/core/dimension.py in __init__(self, data, kdims, vdims, **params)
994 params['cdims'] = d if isinstance(d, Dimension) else Dimension(d): val
995 for d, val in params['cdims'].items()
--> 996 super(Dimensioned, self).__init__(data, **params)
997 self.ndims = len(self.kdims)
998 cdims = [(d.name, val) for d, val in self.cdims.items()]

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/core/dimension.py in __init__(self, data, id, plot_id, **params)
650 params['group'] = long_name
651
--> 652 super(LabelledData, self).__init__(**params)
653 if not util.group_sanitizer.allowable(self.group):
654 raise ValueError("Supplied group %r contains invalid characters." %

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/parameterized.py in __init__(self, **params)
2029 self.param._generate_name()
2030
-> 2031 self.param._setup_params(**params)
2032 object_count += 1
2033

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/parameterized.py in override_initialization(self_, *args, **kw)
808 original_initialized=parameterized_instance.initialized
809 parameterized_instance.initialized=False
--> 810 fn(parameterized_instance,*args,**kw)
811 parameterized_instance.initialized=original_initialized
812 return override_initialization

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/parameterized.py in _setup_params(self_, **params)
950 self.param.warning("Setting non-parameter attribute %s=%s using a mechanism intended only for parameters",name,val)
951 # i.e. if not desc it's setting an attribute in __dict__, not a Parameter
--> 952 setattr(self,name,val)
953
954 @classmethod

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/__init__.py in __set__(self, obj, val)
1217 def __set__(self,obj,val):
1218 """Set to the given value, raising an exception if out of bounds."""
-> 1219 self._check_bounds(val)
1220 super(List,self).__set__(obj,val)
1221

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/__init__.py in _check_bounds(self, val)
1236 if min_length is not None and max_length is not None:
1237 if not (min_length <= l <= max_length):
-> 1238 raise ValueError("%s: list length must be between %s and %s (inclusive)"%(self._attrib_name,min_length,max_length))
1239 elif min_length is not None:
1240 if not min_length <= l:

ValueError: kdims: list length must be between 2 and 2 (inclusive)









share|improve this question






















  • See my answer here: stackoverflow.com/a/55731617/10310883 for you one-liner

    – doppler
    Apr 17 at 15:55













0












0








0








I am trying to do something similar to the OP in this question Geoviews: Add a slider to choropleth map, but it wasn't fully answered. In brief, I have a GeoDataFrame like this:



GeoDataFrame with Polygon geometries



I would like to visualise pre_anom by geometry in a GeoViews map, but I have multiple years for each geometry element. I'd like to have a slider created automatically for the extra kdim year, but if I specify year as a kdim like so:



gv.Polygons(gdf, kdims=['year'], vdims=['pre_anom']).opts(width=600, height=600, 
tools=['hover'], colorbar=True,
cmap='RdBu', color_index='pre_anom',
symmetric=True, toolbar='above',
line_color='white')


I get the following error:



---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-78-0358d9976c72> in <module>
----> 1 gv.Polygons(gdf, kdims=['year'], vdims=['pre_anom']).opts(width=600, height=600, tools=['hover'],
2 colorbar=True, cmap='RdBu', color_index='pre_anom',
3 symmetric=True, toolbar='above', line_color='white')

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/geoviews/element/geo.py in __init__(self, data, kdims, vdims, **kwargs)
98 elif isinstance(data, _Element):
99 kwargs['crs'] = data.crs
--> 100 super(_Element, self).__init__(data, kdims=kdims, vdims=vdims, **kwargs)
101
102

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/element/path.py in __init__(self, data, kdims, vdims, **params)
217 else:
218 params['vdims'] = vdims
--> 219 super(Contours, self).__init__(data, kdims=kdims, **params)
220 if params.get('level') is not None:
221 with disable_constant(self):

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/element/path.py in __init__(self, data, kdims, vdims, **params)
90
91 super(Path, self).__init__(data, kdims=kdims, vdims=vdims,
---> 92 datatype=datatype, **params)
93
94

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/core/data/__init__.py in __init__(self, data, kdims, vdims, **kwargs)
210 datatype=kwargs.get('datatype'))
211 (data, self.interface, dims, extra_kws) = initialized
--> 212 super(Dataset, self).__init__(data, **dict(kwargs, **dict(dims, **extra_kws)))
213 self.interface.validate(self, validate_vdims)
214

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/core/dimension.py in __init__(self, data, kdims, vdims, **params)
994 params['cdims'] = d if isinstance(d, Dimension) else Dimension(d): val
995 for d, val in params['cdims'].items()
--> 996 super(Dimensioned, self).__init__(data, **params)
997 self.ndims = len(self.kdims)
998 cdims = [(d.name, val) for d, val in self.cdims.items()]

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/core/dimension.py in __init__(self, data, id, plot_id, **params)
650 params['group'] = long_name
651
--> 652 super(LabelledData, self).__init__(**params)
653 if not util.group_sanitizer.allowable(self.group):
654 raise ValueError("Supplied group %r contains invalid characters." %

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/parameterized.py in __init__(self, **params)
2029 self.param._generate_name()
2030
-> 2031 self.param._setup_params(**params)
2032 object_count += 1
2033

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/parameterized.py in override_initialization(self_, *args, **kw)
808 original_initialized=parameterized_instance.initialized
809 parameterized_instance.initialized=False
--> 810 fn(parameterized_instance,*args,**kw)
811 parameterized_instance.initialized=original_initialized
812 return override_initialization

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/parameterized.py in _setup_params(self_, **params)
950 self.param.warning("Setting non-parameter attribute %s=%s using a mechanism intended only for parameters",name,val)
951 # i.e. if not desc it's setting an attribute in __dict__, not a Parameter
--> 952 setattr(self,name,val)
953
954 @classmethod

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/__init__.py in __set__(self, obj, val)
1217 def __set__(self,obj,val):
1218 """Set to the given value, raising an exception if out of bounds."""
-> 1219 self._check_bounds(val)
1220 super(List,self).__set__(obj,val)
1221

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/__init__.py in _check_bounds(self, val)
1236 if min_length is not None and max_length is not None:
1237 if not (min_length <= l <= max_length):
-> 1238 raise ValueError("%s: list length must be between %s and %s (inclusive)"%(self._attrib_name,min_length,max_length))
1239 elif min_length is not None:
1240 if not min_length <= l:

ValueError: kdims: list length must be between 2 and 2 (inclusive)









share|improve this question














I am trying to do something similar to the OP in this question Geoviews: Add a slider to choropleth map, but it wasn't fully answered. In brief, I have a GeoDataFrame like this:



GeoDataFrame with Polygon geometries



I would like to visualise pre_anom by geometry in a GeoViews map, but I have multiple years for each geometry element. I'd like to have a slider created automatically for the extra kdim year, but if I specify year as a kdim like so:



gv.Polygons(gdf, kdims=['year'], vdims=['pre_anom']).opts(width=600, height=600, 
tools=['hover'], colorbar=True,
cmap='RdBu', color_index='pre_anom',
symmetric=True, toolbar='above',
line_color='white')


I get the following error:



---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-78-0358d9976c72> in <module>
----> 1 gv.Polygons(gdf, kdims=['year'], vdims=['pre_anom']).opts(width=600, height=600, tools=['hover'],
2 colorbar=True, cmap='RdBu', color_index='pre_anom',
3 symmetric=True, toolbar='above', line_color='white')

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/geoviews/element/geo.py in __init__(self, data, kdims, vdims, **kwargs)
98 elif isinstance(data, _Element):
99 kwargs['crs'] = data.crs
--> 100 super(_Element, self).__init__(data, kdims=kdims, vdims=vdims, **kwargs)
101
102

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/element/path.py in __init__(self, data, kdims, vdims, **params)
217 else:
218 params['vdims'] = vdims
--> 219 super(Contours, self).__init__(data, kdims=kdims, **params)
220 if params.get('level') is not None:
221 with disable_constant(self):

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/element/path.py in __init__(self, data, kdims, vdims, **params)
90
91 super(Path, self).__init__(data, kdims=kdims, vdims=vdims,
---> 92 datatype=datatype, **params)
93
94

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/core/data/__init__.py in __init__(self, data, kdims, vdims, **kwargs)
210 datatype=kwargs.get('datatype'))
211 (data, self.interface, dims, extra_kws) = initialized
--> 212 super(Dataset, self).__init__(data, **dict(kwargs, **dict(dims, **extra_kws)))
213 self.interface.validate(self, validate_vdims)
214

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/core/dimension.py in __init__(self, data, kdims, vdims, **params)
994 params['cdims'] = d if isinstance(d, Dimension) else Dimension(d): val
995 for d, val in params['cdims'].items()
--> 996 super(Dimensioned, self).__init__(data, **params)
997 self.ndims = len(self.kdims)
998 cdims = [(d.name, val) for d, val in self.cdims.items()]

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/holoviews/core/dimension.py in __init__(self, data, id, plot_id, **params)
650 params['group'] = long_name
651
--> 652 super(LabelledData, self).__init__(**params)
653 if not util.group_sanitizer.allowable(self.group):
654 raise ValueError("Supplied group %r contains invalid characters." %

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/parameterized.py in __init__(self, **params)
2029 self.param._generate_name()
2030
-> 2031 self.param._setup_params(**params)
2032 object_count += 1
2033

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/parameterized.py in override_initialization(self_, *args, **kw)
808 original_initialized=parameterized_instance.initialized
809 parameterized_instance.initialized=False
--> 810 fn(parameterized_instance,*args,**kw)
811 parameterized_instance.initialized=original_initialized
812 return override_initialization

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/parameterized.py in _setup_params(self_, **params)
950 self.param.warning("Setting non-parameter attribute %s=%s using a mechanism intended only for parameters",name,val)
951 # i.e. if not desc it's setting an attribute in __dict__, not a Parameter
--> 952 setattr(self,name,val)
953
954 @classmethod

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/__init__.py in __set__(self, obj, val)
1217 def __set__(self,obj,val):
1218 """Set to the given value, raising an exception if out of bounds."""
-> 1219 self._check_bounds(val)
1220 super(List,self).__set__(obj,val)
1221

~/.conda/envs/anaconda3.6/lib/python3.6/site-packages/param/__init__.py in _check_bounds(self, val)
1236 if min_length is not None and max_length is not None:
1237 if not (min_length <= l <= max_length):
-> 1238 raise ValueError("%s: list length must be between %s and %s (inclusive)"%(self._attrib_name,min_length,max_length))
1239 elif min_length is not None:
1240 if not min_length <= l:

ValueError: kdims: list length must be between 2 and 2 (inclusive)






geopandas geoviews






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 13:01









FuzzyDuckFuzzyDuck

1,18910 silver badges13 bronze badges




1,18910 silver badges13 bronze badges












  • See my answer here: stackoverflow.com/a/55731617/10310883 for you one-liner

    – doppler
    Apr 17 at 15:55

















  • See my answer here: stackoverflow.com/a/55731617/10310883 for you one-liner

    – doppler
    Apr 17 at 15:55
















See my answer here: stackoverflow.com/a/55731617/10310883 for you one-liner

– doppler
Apr 17 at 15:55





See my answer here: stackoverflow.com/a/55731617/10310883 for you one-liner

– doppler
Apr 17 at 15:55












1 Answer
1






active

oldest

votes


















0














For reference, while it would be great for this to work seamlessly with the GeoViews one-liner, I have a workaround using Param and Panel:



import pandas as pd
import geopandas as gpd
import geoviews as gv
import param
import panel as pn
gv.extension('bokeh')

opts = dict(width=600, height=600, tools=['hover'], colorbar=True, cmap='RdBu',
color_index='pre_anom', symmetric=True, toolbar='above',line_color='white')

class PreMEI(param.Parameterized):
year = param.Integer(default=2017, bounds=(1980, 2017))

def chloro(self):
return gv.Polygons(gdf[gdf['year']==self.year], vdims=['pre_anom'])

@param.depends('year')
def view_chloro(self):
return gv.DynamicMap(self.chloro).opts(**opts)

p = PreMEI()
doc = pn.Row(p.param, p.view_chloro)


Gives:
enter image description here



BTW, props to the whole PyViz team on a fantastic and still developing package!






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55357840%2fgeoviews-add-a-slider-to-chloropleth-with-polygon-geometries%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    For reference, while it would be great for this to work seamlessly with the GeoViews one-liner, I have a workaround using Param and Panel:



    import pandas as pd
    import geopandas as gpd
    import geoviews as gv
    import param
    import panel as pn
    gv.extension('bokeh')

    opts = dict(width=600, height=600, tools=['hover'], colorbar=True, cmap='RdBu',
    color_index='pre_anom', symmetric=True, toolbar='above',line_color='white')

    class PreMEI(param.Parameterized):
    year = param.Integer(default=2017, bounds=(1980, 2017))

    def chloro(self):
    return gv.Polygons(gdf[gdf['year']==self.year], vdims=['pre_anom'])

    @param.depends('year')
    def view_chloro(self):
    return gv.DynamicMap(self.chloro).opts(**opts)

    p = PreMEI()
    doc = pn.Row(p.param, p.view_chloro)


    Gives:
    enter image description here



    BTW, props to the whole PyViz team on a fantastic and still developing package!






    share|improve this answer



























      0














      For reference, while it would be great for this to work seamlessly with the GeoViews one-liner, I have a workaround using Param and Panel:



      import pandas as pd
      import geopandas as gpd
      import geoviews as gv
      import param
      import panel as pn
      gv.extension('bokeh')

      opts = dict(width=600, height=600, tools=['hover'], colorbar=True, cmap='RdBu',
      color_index='pre_anom', symmetric=True, toolbar='above',line_color='white')

      class PreMEI(param.Parameterized):
      year = param.Integer(default=2017, bounds=(1980, 2017))

      def chloro(self):
      return gv.Polygons(gdf[gdf['year']==self.year], vdims=['pre_anom'])

      @param.depends('year')
      def view_chloro(self):
      return gv.DynamicMap(self.chloro).opts(**opts)

      p = PreMEI()
      doc = pn.Row(p.param, p.view_chloro)


      Gives:
      enter image description here



      BTW, props to the whole PyViz team on a fantastic and still developing package!






      share|improve this answer

























        0












        0








        0







        For reference, while it would be great for this to work seamlessly with the GeoViews one-liner, I have a workaround using Param and Panel:



        import pandas as pd
        import geopandas as gpd
        import geoviews as gv
        import param
        import panel as pn
        gv.extension('bokeh')

        opts = dict(width=600, height=600, tools=['hover'], colorbar=True, cmap='RdBu',
        color_index='pre_anom', symmetric=True, toolbar='above',line_color='white')

        class PreMEI(param.Parameterized):
        year = param.Integer(default=2017, bounds=(1980, 2017))

        def chloro(self):
        return gv.Polygons(gdf[gdf['year']==self.year], vdims=['pre_anom'])

        @param.depends('year')
        def view_chloro(self):
        return gv.DynamicMap(self.chloro).opts(**opts)

        p = PreMEI()
        doc = pn.Row(p.param, p.view_chloro)


        Gives:
        enter image description here



        BTW, props to the whole PyViz team on a fantastic and still developing package!






        share|improve this answer













        For reference, while it would be great for this to work seamlessly with the GeoViews one-liner, I have a workaround using Param and Panel:



        import pandas as pd
        import geopandas as gpd
        import geoviews as gv
        import param
        import panel as pn
        gv.extension('bokeh')

        opts = dict(width=600, height=600, tools=['hover'], colorbar=True, cmap='RdBu',
        color_index='pre_anom', symmetric=True, toolbar='above',line_color='white')

        class PreMEI(param.Parameterized):
        year = param.Integer(default=2017, bounds=(1980, 2017))

        def chloro(self):
        return gv.Polygons(gdf[gdf['year']==self.year], vdims=['pre_anom'])

        @param.depends('year')
        def view_chloro(self):
        return gv.DynamicMap(self.chloro).opts(**opts)

        p = PreMEI()
        doc = pn.Row(p.param, p.view_chloro)


        Gives:
        enter image description here



        BTW, props to the whole PyViz team on a fantastic and still developing package!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 26 at 13:58









        FuzzyDuckFuzzyDuck

        1,18910 silver badges13 bronze badges




        1,18910 silver badges13 bronze badges


















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55357840%2fgeoviews-add-a-slider-to-chloropleth-with-polygon-geometries%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해