Introducing Cartogram Relay (updated 9-6-16)

A simple API for live-charting with Carto + Infogram

UPDATE (9–6–16): In response, Infogram has implemented CartoDB url recognition into their product. No need for the Cartogram shim! This means you can directly plug in your Cartogram SQL API URLs. See Carto’s SQL API documentation for more information if you haven’t used it yet.

Link data, make charts

Though I can count the many exciting data and mapping services that exist in 2016, how do we connect them all together? With live-syncing features in Carto and Infogram, it becomes a matter of simple data standardization.

In Data Services, we are currently examining how to rebuild our core data infrastructure to better serve the Boston region and its data needs. Part of our philosophy is that no monolithic technology solution exists — many great services can work together!

An example of this is Carto and Infogram, both tools we use here at MAPC. While Carto provides an excellent mapping interface, it also acts as a highly flexible, SQL-based data API. This means that formatting and naming can be done using a query language that’s familiar to many urban planners and programmers alike.

Second, Infogram offers a beautiful selection of easy-to-build interactive data visualizations, along with a simple live data feed. Plugin a link to a properly formatted dataset, and you’ve got a live chart that always updates when your data updates.

The problem
Unfortunately, Carto’s data format isn’t compatible with Infogram’s required format. While the JSON API standard exists, it’s not always implemented. That’s why we built Cartogram, a simple API that acts as a tiny layer between Carto and Infogram. It performs the data conversion as needed — you just have to remember the URL! Here’s how to make this all work:

Step 1: Start a new Infogram chart

Once there, click the edit button the chart area itself. The JSON feed button will appear on the left.

Step 2: Build your URL

Infogram’s JSON feed expects a URL. Here is the basic template for pulling data from your Carto account:

https://cartogram-relay.herokuapp.com/infogram?sql=SELECT {{x-axis/series}}, {{columns…}} FROM {{table name}}&user={{yourUserName}}

An example query might be the following:

https://cartogram-relay.herokuapp.com/infogram?sql=select pumatype, aalf_p AS something, aslf_p FROM youth_laborforce_by_race&user=regionalindicators

Step 3: Add the URL into Infogram

Fairly simple! Because this app would be critical infrastructure for running these charts, I’ve provided an instant deploy button in the repository, allowing users to deploy to their own Heroku infrastructure as needed.

Happy live charting!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.