Send an Invite      Sign in   
Tuhunga logo
Sign up now

Plot points on a map - you can do that too!

Written by Jason on September 2, 2010

Today, we’ll highlight a different type of dataset – earthquakes. This dataset is built from U.S. Geological Survey data and contains all magnitude 1+ earthquakes from around the world starting from early August 2010. There are a lot of them. You can add this dataset to your account under the Subscribe tab at no cost.

For this example, we’re going to highlight magnitude 3+ earthquakes in the San Francisco Bay area. Specifically, we want to see any 3+ magnitude earthquakes within a 400km square with San Francisco at the center, and we want to plot them on a map so it’s easy to read. We build our simple filter and report and are able to generate this map in about five minutes:

Let's go through the details on how we generated these results.

The most challenging part of this example is finding the latitude and longitude for San Francisco, and calculating the offsets to form our 200km square. For the sake of simplicity, we’re going to use approximate numbers in this post – you can make your numbers as precise as you like. At San Francisco’s location – 37° 46′ N, 122° 26′ W, or in decimal form, +37.77,-122.43 – one degree of latitude is ~111km, and one degree of longitude is ~89km.

With this information, we want to find earthquakes within our +/- 200km box around the city. Or, using coordinates, +37.77 +/- (200/111) latitude, -122.43 +/- (200/89) longitude. With this data, we’re ready to build our filter. Building filters and reports depend on the knowledge contained in Tutorial #1 – if you haven’t reviewed it yet, we suggest you do so now.


  • Magnitude>3
  • abs(Latitude-37.77)<=200/111
  • abs(Longitude--122.43)<=200/89 (note the double negative on the 122.43 – of course, it could have been a plus sign as well)

The report itself is pretty straightforward. The only nuance we’re using below is putting several pieces of formatted information into the label on the pushpins using the functions concat() – for putting text together – and round() – to keep the numbers to one decimal for display purposes.


  • Latitude
  • Longitude
  • concat("Magnitude ",round(Magnitude,1)," at a depth of ",round(Depth,1)," km")

The graph type is “Map-Lat/Long”, and for settings, we’ll use the line with the concat() function for the label, and, as expected, the latitude uses the field Latitude and longitude is the field Longitude. By expanding the concat() function, we could also have included other items of interest, such as the date and time of the quake, or the distance from San Francisco using a formula similar to the one in the side note below.

That’s all it takes to plot data on a map. But the functionality doesn’t end there. You don’t need to have latitude and longitude to use maps. You may have noticed that one of the other graph type options was “Map-Address” – if you provide a street address, or even just a city or zip/postal code, it can be plotted in the same way.

As a side note, while we used a square box in this example, there’s nothing to stop you from finding quakes within a circle with a given radius – we just used a square to keep the example as simple as possible. To do this, you’ll need to calculate the straight line distance from SF to the epicenter using a formula similar to the following:

  • pow(pow((Latitude-37.77)*111,2)+pow((Longitude+122.43)*89,2),0.5)<300 (300 km radius)

Hopefully this example has given you some ideas as to some of the things Tuhunga can do for you.

Tags: charts, datasets, examples

  About    Contact    Legal    Privacy    Follow us on Twitter  

© 2009 - 2013. All Rights Reserved.