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]]))

No comments:

Post a Comment