首页 > 解决方案 > Animating a geographical heatmap

问题描述

I am using Python and I would like to represent a set of time series on a heatmap.

My static representation of the geographical space, which is a "fixed-time slice" of all the time series, looks like this:

Trentino

Each time serie corresponds to a cell, and every cell is associated to a specific geometric shape on the plot above. Here is an example of one of the time series:

Time serie

Is there any way I can "animate" the heatmap above or at least set a time parameter that I can regulate in order to see the time evolution of the entire map? Obviously the arrays have all the same length and are stored as NumPy arrays in a DataFrame like this:

SQUAREID
155      [0.057949285005512684, 0.04961411245865491, 0....
272      [0.4492307820512821, 0.3846153846153846, 0.415...
273      [0.09658214167585447, 0.08269018743109151, 0.0...
276      [0.03208695579710145, 0.03234782536231884, 0.0...
277      [0.82994485446527, 0.8366923737596471, 0.79620...
                               ...                        
10983    [0.6770833333333334, 0.6865036231884057, 0.692...
10984    [0.21875, 0.22179347826086956, 0.2236956521739...
11097    [0.5921739130434782, 0.5934782608695652, 0.598...
11098    [0.06579710144927536, 0.06594202898550725, 0.0...
11099    [0.21273428886438808, 0.21320286659316426, 0.2...
Name: wp, Length: 2020, dtype: object

and SQUAREID is matched with the cellId column in a GeoDataFrame that looks like this:

    cellId  geometry
0   38  POLYGON ((10.91462 45.68201, 10.92746 45.68179...
1   39  POLYGON ((10.92746 45.68179, 10.94029 45.68157...
2   40  POLYGON ((10.94029 45.68157, 10.95312 45.68136...
3   154     POLYGON ((10.90209 45.69122, 10.91493 45.69100...
4   155     POLYGON ((10.91493 45.69100, 10.92777 45.69079...
...     ...     ...
6570    11336   POLYGON ((11.80475 46.52767, 11.81777 46.52735...
6571    11337   POLYGON ((11.81777 46.52735, 11.83080 46.52703...
6572    11452   POLYGON ((11.79219 46.53698, 11.80521 46.53666...
6573    11453   POLYGON ((11.80521 46.53666, 11.81824 46.53634...
6574    11454   POLYGON ((11.81824 46.53634, 11.83126 46.53601...

6575 rows × 2 columns

Thanks in advance.

标签: pythonpandasplottime-seriesjquery-animate

解决方案



推荐阅读