We talked in the previous blog how to query the USGS earthquake, and plot on the map. Using folium, it is very simple to plot a quick heatmap, in the following we will show how to do that, and you can checkout the script at Qingkai's Github. There are things to add, like the colorbar for the heatmap, specify radius in meters/km instead of pixels, but for now, it is a quick dirty heatmap plot.
In [1]:
from bs4 import BeautifulSoup
import urllib
import folium
from folium import plugins
from functions import *
In [2]:
# let's get the earthquake larger than M5 globally from 2010-01-01 to 2016-01-01.
url = build_query(outFormat = 'text', starttime = '2010-01-01', endtime = '2016-06-01', minmagnitude = 5.0)
# get the earthquake data from USGS and parse them into a numpy array
r = urllib.urlopen(url).read()
soup = BeautifulSoup(r, "lxml")
events_mat = parse_result(soup.text)
In [3]:
# extract lat, lon, and magnitude for the folium heatmap
lats = [float(item[2]) for item in events_mat]
lons = [float(item[3]) for item in events_mat]
mag = [float(item[4]) for item in events_mat]
Heatmap¶
In [4]:
# Using USGS style tile
url_base = 'http://server.arcgisonline.com/ArcGIS/rest/services/'
service = 'NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}'
tileset = url_base + service
m = folium.Map(location=[37.8716, -122.2727], zoom_start=2,\
control_scale = True, tiles=tileset, attr='USGS style')
# I am using the magnitude as the weight for the heatmap
m.add_children(plugins.HeatMap(zip(lats, lons, mag), radius = 10))
Out[4]:
Patanjali yogpeeth Nepal work for nepal earthquake victims and helping them. For more information Please visit my site: - nepal earthquake
ReplyDeleteHeatmap (Heatmap of earthquakes) its very useful blog post!!!
ReplyDeletetop analytics companies
Analytics for Micro Markets
Business Analytics
business data analysis
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