How Far Will Each NBA Team Travel This Year?
Fast Break Article: Travel is tiring. How much will each team do it this season?
Welcome to Fast Break, a series where I’ll spotlight brief sports analytics questions. The goal is to first ask a question, find data to answer it, and then illustrate the process of finding the answer. Each Fast Break will follow the same structure:
The Question
The Answer
The Process
Part 1: The Question
How far will NBA teams travel this year?
NBA athletes are people too. 82 games per year can be taxing on anyone, even if you didn’t have any travel. 41 away games will definitely add to the cumulative effects of a season, and travel time and distance is a factor worth considering.
You could also answer a plethora of research questions using travel data: how do NBA players perform on a long-distance road trip vs at home? How do players perform after flying from one time zone to another? Do rookies play worse on road trips compared to vets? Travel data would be helpful in answering these questions and more.
Part 2: The Answer
The median NBA team travels 42,534 miles this season. If you were to assume a plane flies at 500 miles per hour, that’d be roughly 84 hours in the air, or more than three full days worth of time. Of course, travel isn’t just the time in the air, it’s getting to the airport, getting to a hotel, and sleeping in a bed that’s not your own.
The team that travels the fewest miles this year is the Detroit Pistons at 34,766 miles traveled. The farthest team travel is the San Antonio Spurs who have a whopping 51,079 miles of travel (including a Paris trip) ahead of them. These distances obviously depend on (1) where the team is located and (2) how close the team is to its divisional and conference counterparts. Scheduling itself can get quite messy and is not the main focus of this write-up. If you’re interested in learning more, this 2016 project by a Carnegie Mellon student is a pretty cool starting point for further investigation.
Part 3: The Process
Because the schedules were only released yesterday, there were a couple of hurdles and fun fixes when putting together the data:
Getting information on teams, location of the game, and game time
This first step isn’t usually actually too big of a challenge, but because the schedule was so recent at the time, even Basketball Reference didn’t have schedules on their site. Luckily, the NBA posts a JSON file of the entire schedule, and it was fairly simple to turn this into a dataframe. This data included everything that I was hoping, and then all that had to be done was add game locations.
Get longitude and latitude coordinates for each NBA city
There are a million ways to do this second step, but the easiest I found was the free Google Sheets extension GeoCode. To get this in the appropriate format, I selected the columns of interest and then exported as a CSV file for google sheets. I ran GeoCode and to my pleasant surprise it worked well! I then re-downloaded the file and brought the csv back into statistical computing software.
Get a schedule for each NBA team
The current form of the dataframe I had was a list of all games. In this list was the home team, away team, game time, and coordinates. This was a great starting point but I wanted to be able to track each individual team’s season. To do this, I created a list of dataframes, and filtered each object in the list to be a subset of games that match either the home or away team to the current team in the list. Now, I had a list of dataframes, with each dataframe being a unique team’s schedule.
Calculate travel distance
To calculate travel distance, I used the Haversine formula, which allows for distance to be calculated between two points on a sphere given longitude and latitude. R’s ‘geosphere’ package includes a disthaversine function that allows the distance to be calculated.
First, I added an arbitrary “game” at the start of each season’s schedule, located in their home city. This was so if the team’s first game was away, travel distance would be tracked accordingly. Then, I went through each game of the season (within each team’s schedule) and looked at the distance between the current and previous game. I stored this in a new column of the original dataframe.
Do what you will!
My resulting dataframe (really list of dataframes) was exactly what I hoped for. Each team’s season schedule, sorted by date, with distance traveled for each game listed. The final caveat is the in-season tournament, the newly named Emirates NBA Cup has not been scheduled yet, so each team only has 80 games on the docket. The rest of the season will presumably be scheduled after the group games of the Emirates NBA cup have concluded.
Final Thoughts
Were there easier ways to do this analysis? Maybe!
Did I accomplish the goal of answering the simple question? Yes
Did I make a calculation error, and display a bunch of incorrect numbers? I sure hope not.
With this type of calculation, there’s always room for error and improvement. If you notice anything seems especially off, please leave a comment. To the best I can tell though, the travel distances seem good to me! I’ve spot checked a couple distances, as well as looking at previous years’ data, and all of that seems to be consistent.
Lastly, if you’re interested in obtaining this full dataset, with a team’s schedule and how far they travel from game to game, please leave a comment and I’ll be sure to get it to you. Thanks for reading, and stay posted for this season’s win projections in the near future!
Like the article, could I get the data set, please?