Monday, April 18, 2016
Visualizing Sports Data with Maps
Interactive mapping platforms can be a very simple but effective way to visualize sports data. They are particularly effective for creating shot-maps for ball based team sports, e.g. football, soccer, baseball and basketball.
Last week the Los Angeles Times created a very impressive visualization of every shot made by Kobe Bryant in his long career. Every Shot Kobe Bryant Ever Took allows you to explore a shot map of Kobe Bryant's 30,699 career shots, both successful and misses.
This weekend Kudos created their own basketball shot map using the CartoDB mapping platform. The Golden State Warriors Map allows you to analyze every game played by the Golden State Warriors in their record breaking 2015-16 season.
Using the map you can explore and analyze trends in shot locations, players, shot types, opponents, periods and clock times over the entire NBA season.
Creating this kind of sports visualization is very easy with an interactive mapping platform (as long as you have the data). Essentially you just need to create a map element without any base map tiles. You can then create your own pitch map using polylines. To create your shot map you just need to add a marker to the map for every shot.
The only tricky part in creating your visualization is converting your pitch based co-ordinate system to the co-ordinate system used by interactive maps.
I created this very crude soccer viz example in a couple of hours. To draw the pitch I started at 0 degrees of latitude and 0 degrees of longitude. I then created a simple co-ordinate system by equating one degree of latitude or longitude to one yard. So to draw a line to show the 100 yard goal-line of a soccer pitch I just need to draw a polyline from (0,0) to (0,100). I then created the other lines on the pitch using the same co-ordinate system.
Plotting the shot map is just as simple. If you think of (0,0) as the bottom corner of a graph it is a simple matter of plotting each shot position by adding the distance from the left touchline and the distance from the goal-line. So a shot taken 25 yards in from the touchline and 30 yards from the goal would have a lat-long marker position of (25,30) on the map.