As a data journalist, it is a near certainty that at some point you’ll be dealing with the sort of data that’s best visualized by being plopped down on a map. Creating a map allows readers to quickly get a feel for geographic trends and can reveal more than a simple bar or pie chart would.
So, we’re going to walk you through the process of how to actually make a data map. There are a bunch of services out there that allow you to do this simply, including Plot.ly and Carto. For our purposes, though, we’re going to be using Tableau.
The dataset we’ll be working with is all Airbnb listings in the city of Boston. We’ll be plotting out all of the listings by location, and then color-coding them by average review rating. You can access it here if you want to follow along. Here we go!
Setting up and verifying your data
It sounds obvious, but before anything else, you have to verify that your dataset has the right qualities to be turned into a map. Somewhere in the columns, there must be values for longitude and latitude. Tableau (and other) mapping services can take those data points and plot them on a map automatically, but they won’t if there’s only an address. Luckily for us, our listings have latitude and longitude for every Airbnb location.
Cut down your data to include only the columns you need. This is a super-rich dataset with a lot of information, but for our purposes, we only really needed to know the average review score and the coordinates. We copied the dataset into a separate sheet to preserve its integrity, and then deleted all columns except ID number, listing URL, latitude, longitude, and review score. (We kept those other ones so we could keep track of what property we’re actually looking at.)
Using Tableau to Express the Data
Go ahead and boot up Tableau. There’s an option in the opening screen that allows you to connect an Excel spreadsheet. Click on that and choose the dataset from your files. From here, your column names will show up in the boxes along the left side. Choose “Map” as your chart type. Now, drag “Latitude” and “Longitude” from those boxes along the side to the top so longitude is next to the Columns label and latitude is next to the Rows label.
At this point, you want to make sure the columns you exported into Tableau are defined correctly. Set “Listing Url” and “Id” as dimensions and set “Latitude,” “Longitude,” and “Review Scores Rating” as measures. This tells Tableau to see the URL and IDs as attributes, and use latitude, longitude, and review rating as figures to work with.
Create some sets. The review scores we’re working with are on a scale of 0-100, and there are too many unique values to express them all individually. So, we need to create intervals that Tableau will recognize. To do this, look at the box for “Sets” under “Measures” and “Dimensions.” Click on the box and create a set for each interval of ten, so it looks like this:
Great, now you have sets, which break down our data in a useful way. Drag all of those new sets under “Marks,” so they actually show up on the map.
Now, you’ll need to edit each set so they include the proper range of values. This “Edit Set” window will display a list of all unique values in the Review Scores Ratings column. Title your set with the correct range, and then click each value that falls into the interval in question. This is less work than it looks, since Tableau doesn’t generate repeat values, as shown below. Repeat this for every set. (Note: If you’re working with a smaller/simpler dataset, this may not even be necessary, we just found it the easiest way to deal with this particular dataset.)
At this point, Tableau should automatically have your data mapped out. Only problem is, Tableau doesn’t choose a very good color scale to represent the different ranges. This is an aesthetic aspect, but an important one. Click on “Color” in the “Marks” box, then click “Edit Colors.” This will show you your ranges along with a color palette. Click on each range and choose your desired color.
You’re pretty much done. From here, you just want to make sure your legend is formatted correctly and to give your map a title. Tableau automatically will generate a legend for you, but we decided to make our own that was a little more clear, and tack it on at the end.
The map would seem to indicate that most listings in Boston fall between 50 and 89 in terms of review score. So, they’re decent. There are a handful of really ritzy ones — especially as you get farther out — as well as a peppering of really terrible ones, especially in Allston. Beyond that, you can see that Airbnbs are clustered around downtown, Fenway, Back Bay, and the North and South Ends. There are far fewer in Dorchester and Mattapan, which makes sense, since access to public transportation is unfortunately more limited. Plus, visitors from out of town probably want to be closer to downtown.
Fun fact: When we originally perused our dataset, we noticed that someone had rated a Jamaica Plain Airbnb poorly… based on location. Maybe these out-of-towners should stick to hotels.