holoviz / geoviews

Simple, concise geographical visualization in Python
http://geoviews.org
BSD 3-Clause "New" or "Revised" License
577 stars 75 forks source link

Can we create choropleth from shapefile with multiple dimensions such as time? #61

Closed pkmn99 closed 7 years ago

pkmn99 commented 7 years ago

I am not sure if we can make a choropleth from shapefile with time dimension with geoviews right now. I could't find any info for this in the documentation. In the UK referendum example, (http://geo.holoviews.org/Geometries.html), can we use population over the years to make a similar map but with time change? This can be easily done with nefcdf data, this feature could be very useful for shape files as well.

pkmn99 commented 7 years ago

I figured out how to do this. Just combine Ndoverlay objects of different years to holomap.

frequencies = [2000, 2010]
holomap = hv.HoloMap(kdims=['Frequency'])
temp = [map_2000, map_2010]
for i, frequency in enumerate(frequencies):
    holomap[frequency] = temp[i]
jlstevens commented 7 years ago

Glad you found a solution!

Looking at your code, I believe it is also equivalent to this:

frequencies = [2000, 2010]
temp = [map_2000, map_2010]
hv.HoloMap({f:temp for f,temp in zip(frequencies, temp)} kdims=['Frequency'])
pkmn99 commented 7 years ago

Hi jlstevens, many thanks for a simplified code! I am not very familiar with list comprehension and this is a good example for me to learn.

philippjfr commented 7 years ago

That said, I think there's probably something we can do to automate this within the Shape.from_shapefile method as long as your dataframe contains information for different years. I'll think about it and get back to you.

pkmn99 commented 7 years ago

Hi philippjfr, I've been thinking about the same thing. That would be perfect, exactly what it needs.

pkmn99 commented 7 years ago

Is there a way to set color range for the choropleth created from shapefile? I have seen some strange problems. Not sure if they are bug, probably will open a new post to report it.