Skip to content

Instantly share code, notes, and snippets.

@mehak-sachdeva
Last active April 13, 2017 00:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehak-sachdeva/a3171aff327668d7bbfad218f6a25aa1 to your computer and use it in GitHub Desktop.
Save mehak-sachdeva/a3171aff327668d7bbfad218f6a25aa1 to your computer and use it in GitHub Desktop.

Mapping and Visualization with CARTO

< 04.12.2017>

Grab this page here: http://bit.ly/viz-with-carto

Me, Map Scientist at Carto

Intro

Accounts at Columbia

Columbia has a CARTO site license where you get primo accounts :) If you don't have an account on this already, head to:

https://columbialibraries.carto.com/signup

Make sure to use your columbia.edu email address to signup.

Builder vs. Editor

CARTO is in the middle of upgrading all accounts from our old product (Editor) to the current one (Builder). If your account looks different from ours, let us know and we'll get you upgraded.

Using CARTO you can:

  • easily overlay data onto a map
  • analyze the data to reveal spatial patterns
  • tell stories by creating beautiful visualizations
  • and then share them with the world!

CARTO combines

Add it up and you roughly get CARTO.

Diagram of CARTO's architecture

Structure of CARTO

Open source

Look at our code! Find the errors bugging you, improve it, be a part of a community.

http://github.com/CartoDB/cartodb

Intro to Builder

Welcome to Carto Builder!

Session I:

A peek at the map for this session: Albatross Tracking Map

albatross

The inspiration for this was based on this amazing article by Nat-Geo. You can get all kinds of cool datasets on animal tracking from Movebank.org

Download the Dataset for this session HERE

  • Style
  • Animated Styling
  • Connect with Lines

screen shot 2016-12-13 at 10 30 00 am

  • Turbo-Carto (CartoCSS)
#layer {
  line-width: 2;
  line-color: ramp([category], (#5F4690, #1D6996, #38A6A5, #0F8554, #73AF48, #EDAD08, #E17C05, #CC503E),
                               ("1163-1163", "3275-30662", "4261-2228", "4266-84831108", "unbanded-153", "unbanded-154",                                       "unbanded-156", "unbanded-159"), "=");
  line-comp-op: screen;
  line-dasharray: 1;
}

screen shot 2016-12-13 at 10 41 23 am

Session II:

Hands on: Earthquake Reporter

Importing the data

First we need to sync a new dataset. Search for "usgs earthquake spreadsheet" to find the page, or use the following dataset of all recorded seismic events from the past 30 days:

http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.csv

This is updated every 15 minutes, so it's a great candidate for making a map which updates based on measurements in the world. Let's import that into our accounts. Even cooler: the map we publish will be updated automatically, and the underlying analysis changes dynamically based on the new points added to the dataset.

Building the analysis workflow

To build our analysis workflow, let's focus on the output we would like.

Visualize significant, recent earthquake events by communicating the total population who are living within 50 miles of the epicenter.

We can build this analysis workflow in the Builder by chaining together some of the tools.

  1. We need to restrict our analysis to California (within 50 miles of the borders)
  2. Filter to only show significant events
  3. Find the number of people living with 50 miles of the earthquake events
  4. Visualize the points by the number of people (proportional symbol map)

Getting California

There are many ways to get the boundary of California. One ways is just grab all the states from Natural Earth Data. Another ways is to grab it from my CARTO account:

http://mehak-carto.cartodb.com/api/v2/sql?q=SELECT%20*%20FROM%20us_states&format=shp&filename=us_states

Copy that link, and import it just like you did for the earthquake dataset above. Finally, we can do some Analysis with the Builder to get it into the state that we're interested in (50 miles outside of current borders).

Finding Earthquakes that happened in or around California

We can again use the Builder to find all earthquakes which intersect California or are within 50 miles of its border by using the "Aggregate intersection" method.

Filtering out non-significant events

Using the "Filter by column value" analysis method, we can surface only the significant earthquakes (by magnitude).

Finding 50 mile buffers

Using the "Create areas of influence" tool, we can get the regions that are within a 50 mile distance of the epicenter of an earthquake.

Enrich with the Data Observatory

This analysis allows us to attach valuable information from sources such as the US Census. For our demo we will use Total Population that are within 50 miles of the epicenter of the earthquakes.

Visualize by the number of people

Analysis Chain

Questions? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment