Friday, June 24, 2016

Using folium - 5: Image Overlay (Overlay Shakemap)

In this blog, we will try to overlay a static image to folium map. We will use the shakemap example from the 2014 M6.0 Napa Earthquake. You can download the shakemap Intensity Overlay KMZ File, and get the png file after unzip it. The boundary of the image can be found in the overlay.kml file. 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')

# Overlay the image
map_.add_children(plugins.ImageOverlay(data, opacity=0.8, \
        bounds =[[min_lat, min_lon], [max_lat, max_lon]]))
map_
Out[2]:

5 comments:

  1. Hey, thank you for the post. Although I want to confirm the projection the image follows? Is it spherical mercator or lambert conformal?
    It's just that I have created an image using Basemap - python which is in "lcc"/"merc" projection but when I try to superimpose it over Folium; the alignment is quite skewed.
    Thank you!

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Five 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