how to generate a heatmap in ipyleaflet

Viewed 1563

I have multiple coordinates (latitude and longitude) and I would like to create a heatmap. I have checked all the documentation online and examples and cannot find anything which helps my to create a heatmap on an ipyleaflet map.

Please could someone advise how I generate and add a heatmap layer onto an ipyleaflet map.

I am working inside a jupyter notebook.

Thanks

1 Answers

Since the last version of ipyleaflet it is now possible to create a HeatMap:

from ipyleaflet import Map, Heatmap
from random import uniform

m = Map(center=[0, 0], zoom=2)
locations = [
    [uniform(-80, 80), uniform(-180, 180), uniform(0, 1000)] # lat, lng, intensity 
    for i in range(1000)
]
heat = Heatmap(locations=locations, radius=20, blur=10)
m.add_layer(heat)

# Change some attributes of the heatmap
heat.radius = 30
heat.blur = 50
heat.max = 0.5
heat.gradient = {0.4: 'red', 0.6: 'yellow', 0.7: 'lime', 0.8: 'cyan', 1.0: 'blue'}

m
Related