stat157 / recent-quakes

Stat 157 Homework 2 due on Monday 2013-10-21 at 11:59pm
0 stars 20 forks source link

Folium/Leaflet.js - an alternative way to plot the earthquake data #14

Open kqdtran opened 10 years ago

kqdtran commented 10 years ago

Folium is a Python package we found out in OH today, and my group proceeded to install and play around with it as an alternative to BaseMap for plotting quakes. It allows you to plot the data in as few as 3 lines of code, using Leaflet.js under the hood.

Leaflet is a Javascript library with awesome interactive maps (and it's also mobile-friendly!). Everything is done in Python using Folium, so there's no html/css/javascript involved.

You can take a look at the examples in the docs to get started with Folium. Here's the interactive earthquake map my group made today http://bl.ocks.org/kqdtran/7063887. It's not really polished yet, but I guess it kinda works. The circle's radius is the magnitude of the quake, and if you click on the circle, it should show the information about the earthquake.

If you decide to play around with Folium, keep us all posted how that goes!

Edit: To install Folium, run sudo pip install folium on the command line!

j-zhang commented 10 years ago

Thanks for sharing this other resource with us Khoa!

I opened up your interactive earthquake map in a new window, http://bl.ocks.org/kqdtran/raw/7063887/, and at first I didn't see the dots for earthquakes since I was going left on the map, and didn't see the one for Eureka, CA. But then when I opened the map again going in the rightward direction, I found all the earthquakes that you had plotted.

Just out of curiosity, do you have any idea why this might be? Since if you keep browsing in either direction, you come upon a number of North Americas...and the continents repeat themselves.

kqdtran commented 10 years ago

I unfortunately don't, Jody :(. Folium is still pretty new, so I haven't been able to google for any explanation yet. I'll just ask on the Issue Tracker of Folium itself and see what they say.

I guess an alternative and less confusing way would be to show the map once, so there should be no repeated continents... But I'll look into that.

j-zhang commented 10 years ago

Understood, was just an observation since I initially had trouble finding the earthquakes.

Also, if you plot all of the 1,000+ earthquakes in the last week with magnitude 1.0, the map would get filled with clusters of earthquakes, right? I'm curious if even in California, for example, it would be harder to differentiate between earthquakes since the dots are pretty large right now. This is an interesting tool though, and many considerations to be made...maybe my group will look into this as a resource!

Right now we've been adjusting the existing code, and testing it on California, but are having trouble getting the right latitude and longitude coordinates as boundaries to the map, so the outline of California is not as clearly outlined like Alaska is. I did find this site: http://peak5390.wordpress.com/2012/12/08/matplotlib-basemap-tutorial-making-a-simple-map/, as a helpful resource for understanding how to use the matplotlib basemap tool. They were also interested in plotting global earthquake activity...

kqdtran commented 10 years ago

Right! I actually purposely make the dots big because I know the quakes are far apart. :D If the dots are a bit smaller, you can zoom in to the map to see different quakes happening in California as well.

That was a great link! Tbh though, I looked over the BaseMap tutorial and it seemed really complicated... so that's when we switched over to Folium...

aculich commented 10 years ago

I'm looking forward to seeing what you've done with Folium as an HTML5 alternative to using the IPython Notebook w/Basemap

kqdtran commented 10 years ago

Found this on HN http://sensitivecities.com/so-youd-like-to-make-a-map-using-python-EN.html, looks pretty relevant to what we're doing :D

j-zhang commented 10 years ago

:+1: