Skip to content

Create sql database of nba player tracking coordinate data

Notifications You must be signed in to change notification settings

jasonpchang/nba_playertracking_sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

nba_playertracking_sql

Create your own database of NBA data in its rawest form using Python and SQL

NOTE 2018.02.01: data no longer available at http://stats.nba.com/stats/locations_getmoments/?eventid=1&gameid=0020800001

Getting started

The NBA's player tracking data provides a wealth of information because it contains data in its rawest form: player and ball coordinates at 40 ms time sampling. In theory, nearly all traditional basketball stats can be derived from these data.

To obtain these data, you must scrape the data off the web. I've done that for you by writing a Python script that scrapes the data and organizes it in an SQL database. All you need to do is run a single line of code, providing the beginning and end dates of games you are interested in. For instance, if you want to grab data from all games between March 1, 2015, and May 1, 2015, and place the data in a database called example.db, run the following code:

./src/scrape_nbaptmov.py 03-01-2015 05-01-2015 ./dat/example.db 1

After you have built your database, you can use the script read_movements.py to plot the movement data over time. The only argument required is the name of the database.

./src/read_movements.py ./dat/example.db

About

Create sql database of nba player tracking coordinate data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published