In this blog, let's build on the blog from last week that we add a layer control to turn on/off the intensity layer we overlay on the map. All we need is to add two lines to have this control. You can find the script at Qingkai's Github.
In [1]:
import folium
from folium import plugins
from scipy.ndimage import imread
In [2]:
# boundary of the image on the map
min_lon = -123.5617
max_lon = -121.0617
min_lat = 37.382166
max_lat = 39.048834
# create the map
map_ = folium.Map(location=[38.2, -122],
tiles='Stamen Terrain', zoom_start = 8)
# read in png file to numpy array
data = imread('./ii_overlay.png')
Intensity = plugins.ImageOverlay(data, opacity=0.8, \
bounds =[[min_lat, min_lon], [max_lat, max_lon]],\
attr = 'Shaking Intensity')
# add a name to the layer
Intensity.layer_name = 'Shaking Intensity'
# Overlay the image
map_.add_children(Intensity)
# add the layer control
folium.LayerControl().add_to(map_)
map_
Out[2]:
What is layer control used for? Can this be used for routing control ?
ReplyDeleteAlso, does folium support leaflet routing machine?
DeleteThis comment has been removed by the author.
ReplyDeletecan i add a radio button for layers
ReplyDeleteif so can u help me with an example
ReplyDeleteFive weeks ago my boyfriend broke up with me. It all started when i went to summer camp i was trying to contact him but it was not going through. So when I came back from camp I saw him with a young lady kissing in his bed room, I was frustrated and it gave me a sleepless night. I thought he will come back to apologies but he didn't come for almost three week i was really hurt but i thank Dr.Azuka for all he did i met Dr.Azuka during my search at the internet i decided to contact him on his email dr.azukasolutionhome@gmail.com he brought my boyfriend back to me just within 48 hours i am really happy. What’s app contact : +44 7520 636249
ReplyDelete