I used to play basketball and I do a lot of data analysis and mapping, but I haven't actually blogged about it before, so here I am. Scroll to the bot

A Wee Bit of Mapping: A long read about NBA shot data

submited by
Style Pass
2024-03-29 19:00:10

I used to play basketball and I do a lot of data analysis and mapping, but I haven't actually blogged about it before, so here I am. Scroll to the bottom of this post if you want to see an old photo of me and some other Scottish basketball players standing beside Shaq. Otherwise, read on!

You can get NBA shot data via the NBA API but there are lots of other ways, and some kind people on the internet have already shared it themselves, so that's what I'm using here, thanks to Dom Samangy. In order to add something useful, and so that people can map shot data against a real NBA court I also created a folder where I shared various files that can be loaded into QGIS (or other software) so that the NBA shot data isn't just loads of points floating in space. When you add all shot data for the 2003-04 season to the 2022-23 season, plus my NBA court files, it looks like this, below - over 4 million shots! I loaded up the full csv and then converted it to a SQLite database and it works really quickly in QGIS.

Okay, so looking at over 4 million shots doesn't really tell us much, even if it is quite interesting. What is a lot more interesting is being able to filter and query the data in all manner of ways since we have lots of different columns associated with each point - like the date, who took the shot, whether it was a make or a miss and all sorts of stuff. If you're an NBA fan like I am then you can query it to find particular games or players - although just bear in mind that the data I've linked to above that I'm using here only covers the regular season. But it covers a 20 year period of NBA history where the game has changed in significant ways - not least of which is the rise of the 3-pointer. 

Leave a Comment