In Game 5 of the 2026 NBA Finals, the New York Knicks scored their first points on a Jalen Brunson 3 point shot. Figure 1 shows an animation of the same play in which players are represented as dots (colored according to their team) move aross the plane (representing the court)
Figure 1: Animation of Knicks possession leading up to a Brunson 3 point shot
We will recreate this figure using recently-released tracking data from the NBA.
Tracking Data in the NBA
NBA teams have used cameras to collect player tracking data during games since the 2009-10 regular season. Initially, the league used SportVU, a system of six cameras and proprietary computer vision software initially developed for soccer. In 2013, the league announced a partnership with STATS, LLC to deploy SportVU in all arenas and collect & distribute the data league-wide. That partnership was renewed for the 2016-17 season before the league switched to a different vendor (Second Spectrum) for its optical tracking data. Before the 2023-24 regular season, the NBA announced a new partnership with Sony’s Hawk-Eye Innovations to deploy Hawk-Eye’s 3D optical tracking system in all arenas.
Unlike the NFL, the NBA has been extremely reluctant to release any of its tracking data to the public. Much of the public research1 based on these data has been done by groups who received special access. Despite the lack of formal data releases, some NBA tracking data has still made it to the public domain.
During the 2014-15 regular season, the NBA added a feature to its website in which fans could watch video clips of individual players’ shots and visualize the player & ball movements as dots moving around the court. Neil Johnson found the data underpinning this functionality, scraped it, and shared all that data publicly on GitHub2. In total, he got 632 games worth of data before the data were taken offline (and the NBA removed the tracking data visualization functionality from its website)3. Since the data were publicly posted, many people have developed code for processing, analyzing, and visualizing these data. I recommend this repository from Rajiv Shah if you want to play around with the older tracking data.
For the better part of a decade, these 632 games from the 2015-16 regular season were the only publicly available NBA tracking data until recently. In October 2026, the NBA announced several new features to its app including Game Pulse which, to quote the NBA’s press release “combines live court visualization… in a live-updating experience.” In other words, the dots on the court had returned and Neil Johnson once again found the underlying data, scraped it, and posted it publicly4.
We will work with a portion of these data to create an animation of a single possession from Game 5 of the 2026 NBA Finals.
Getting Started with Tracking Data
The full data archive (which is about 5GB in size) contains several files and a large directory containing the tracking data. That directory contains sub-directories (one for each day) and each day’s directory contains sub-directories (one for each game). The games are uniquely indexed by a 10-digit numeric id. For instance, the ID for Game 5 of the 2026 Finals is 0042500405.
Each game’s directory contains several JSON files5. Player-tracking data is incredibly structured: player coordinates are nested within frames and frames are nested within games. This makes JSON particularly well-suited for storing tracking data.
NoteInstalling jsonlite
To work with data stored in JSON format, you will need to install the jsonlite package using the code install.packages("jsonlite")
We will start by exploring the data contained in the file metadata.json. Note that R will usually read JSON files in as large named list.
Many of the attributes in the game’s metadata are self-explanatory (e.g., game_id and game_data). It turns out the game element is itself a list and contains loads of information including the identities of the teams and players involved in the game.
Found 500 records...
Found 1000 records...
Found 1500 records...
Found 2000 records...
Found 2500 records...
Found 3000 records...
Found 3500 records...
Found 4000 records...
Found 4500 records...
Found 5000 records...
Found 5500 records...
Found 6000 records...
Found 6500 records...
Found 7000 records...
Found 7500 records...
Found 8000 records...
Found 8500 records...
Found 9000 records...
Found 9500 records...
Found 10000 records...
Found 10500 records...
Found 11000 records...
Found 11500 records...
Found 12000 records...
Found 12500 records...
Found 13000 records...
Found 13500 records...
Found 14000 records...
Found 14500 records...
Found 15000 records...
Found 15500 records...
Found 16000 records...
Found 16500 records...
Found 17000 records...
Found 17500 records...
Found 18000 records...
Found 18500 records...
Found 19000 records...
Found 19500 records...
Found 20000 records...
Found 20500 records...
Found 21000 records...
Found 21500 records...
Found 22000 records...
Found 22500 records...
Found 23000 records...
Found 23500 records...
Found 24000 records...
Found 24500 records...
Found 25000 records...
Found 25500 records...
Found 26000 records...
Found 26500 records...
Found 27000 records...
Found 27500 records...
Found 28000 records...
Found 28500 records...
Found 29000 records...
Found 29500 records...
Found 30000 records...
Found 30500 records...
Found 31000 records...
Found 31500 records...
Found 32000 records...
Found 32500 records...
Found 33000 records...
Found 33500 records...
Found 34000 records...
Found 34500 records...
Found 35000 records...
Found 35500 records...
Found 36000 records...
Found 36500 records...
Found 37000 records...
Found 37500 records...
Found 38000 records...
Found 38500 records...
Found 39000 records...
Found 39500 records...
Found 40000 records...
Found 40482 records...
Imported 40482 records. Simplifying...
closing gzfile input connection.
In total, the tracking data file contains nrow(raw_data) lines, with each line representing a single frame, and several different “columns”7
The variables timestampe_ms and timestamp_utc record the timestamp for each frame. It turns out that during game play (i.e., when period is not NA), the frames are sampled approximately every 200 milliseconds. The gaps are due to a combination of missing tracking data and stoppage periods.
We see that there are some frames with no player locations recorded and other frames with 10 players. For simplicity, we will focus only on the frames with at least one and no more than 10 player locations recorded.
In each frame (i.e., line/row in tracking_data), the player and ball locations are saved in home_players, away_players, and ball. These are saved as individual data frames. For instance, here are the home team locations at a single frame
We will loop over every frame in tracking_data and save the player & ball coordinates in a data table. We will temporarily save these frame-level tables in a list and then concatenate them all at the very end.
2
Create a single table with all home and away players
3
Extracts the individual coordinates into three separate columns
4
Removes the xyz variable, which stored coordinates in a single vector
5
If we have available ball coordinates, we’ll save those too
6
So that we can put ball and player coordinates in a single table, we’ll give the ball a player_id and team_id of 0L. The L records this as an integer and not a double
7
Combine the player & ball data and add columns recording the frame number, game clock and timestamps
8
Concatenate across frames and also join in player names and jersey numbers
Joining with `by = join_by(player_id)`
Animating a Single Play
We will focus on the first made shot by the Knicks in the game — a successful 3 point shot by Jalen Brunson. To do this end, we create a single data frame where the game clock is between 9:48 and 9:28 in the first quarter.
We can visualize the entire trajectory of Brunson, one Spurs defender (Stephon Castle), and the ball over the span of these 20 seconds. Importantly, the coordinate system places the origin at mid-court. Regulation NBA courts measures 94 ft by 50 ft so the court coordinates are in the range \([-47,47] \times [-25, 25]\).
The playable area is 94ft x 50ft but we will set a larger plot range to account for the apron (i.e., the out-of-bounds areas surrounding the court).
2
Boundary of the court
3
Halfline
4
Center of the rim is 5’3” away from the baseline and has a 9” internal radius
5
Box inside the key measures 19’ x 12’ and the whole key measures 19’ x 16’
6
Circular part of the three point arc has a radius of 23’9” and 22” to the corner. With a bit of trigonometry, we can figure out how much of the circular arc to draw
7
Compute how far the three point line extends parallel to the sidelines and perpendicular to baseline. Then add horizontal lines connecting to the arc.
8
The restricted area is formed with a half-circle of radius 4’ from the center of the basket and extends to the baseline.
9
The backboard measures 6’ across and its front edge is positioned 4’ from the baseline
10
The circle at the top of the key measures 6”.
Frame-by-Frame Illustration
To create an animation, we will make a separate image showing all players and the ball in each frame. Then, we can stitch those images together into a GIF. To simplify this process, we define a function in the codeblock that plots the locations in each frame.
In order to create an animation, we can plot the player and ball location in each frame and stitch them together into a GIF using ImageMagick. You will first need to download the binary associated with your system from the ImageMagick website and follow the appropriate installation instructions. Then, once you have saved the frame-by-frame images sorted chronologically by frame number in a directory, you can use the command magick to create a GIF. Full documentation for creating such animation is available here. The most salient option to run with magick is delay, which controls the length of the pause between images. Since the NBA data is sampled every 200ms, we will specify the option -delay 20 to match the 5 frames per second rate in the data.
ImportantSubdirectory for Images
In the codeblock below, I set the variable target and use it when calling png. This is the name of a sub-directory that I created within my working directory to hold the frame-by-frame images. If you want to run this code locally, you will need to create a similar sub-directory and update the assignment of target with that sub-directory’s name.
If you want to know more about why JSON and JSON Lines are useful, check out this article from NCBI.↩︎
Rather than viewing the data as a traditional table, it’s better to think of it as a list with each element having the same length (and arranged in the same order)↩︎