I have a geodataframe (map) that has two columns -- one is id, one is POLYGON info:
ID | geometry |
---|---|
H1 | somevalue |
H2 | somevalue |
H3 | somevalue |
And I have another dataframe (data) that contains id and value:
ID | value1 | value2 |
---|---|---|
H1 | 1 | 2 |
H2 | 2 | 3 |
H3 | 3 | 1 |
I wanted to create an animated heatmap so that the plot will change according to values1, value2, value3 .....
Here is my code. Now it can only display the first heatmap (based on value1).
fig, ax = plt.subplots(1, figsize=(10, 6))
def update(i):
z = data.iloc[:,i]
heatmap = pd.DataFrame(map)
heatmap['value'] = z
heatmap = gpd.GeoDataFrame(heatmap)
variable = 'value'
heatmap.plot(column=variable, cmap='Reds', linewidth=0.8, ax=ax, edgecolor='0.8')
return heatmap,
anim = animation.FuncAnimation(fig, update, repeat=False, interval=20, blit=True)
plt.show()