Saturday, March 23, 2024

A long read about NBA shot data

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!

NBA shot data

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.

That's a lot of shots

Explore the data

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. 


With that in mind, let's look at made 3 point shots in 2003-04 (left) vs 2022-23 (right). Lots more threes recently, big surprise! But what about if we filter it by position and look at made 3-pointers by centers in 2003-04 vs 2022-23? Well, in 2003-04 there were 149 made 3-pointers by centers vs 2,138 in the 2022-23 season. Dirk played center for the Mavs in a few seasons, including 03-04 so he actually accounted for 99 of the 149 that year. Vlade Divac had two, Ben Wallace had one.

A not very surprising change

Dirk scored 99 of these!

Brad Lohaus? Anyone?

Asking questions and finding answers

If you're a hoops fan, and know what you're doing with data you can use this dataset to ask and answer all sorts of interesting/random questions about NBA shots over the years. For example, if I wanted to find out how many shots have been taken from the backcourt in the 20 seasons from 20003-04 to 2022-23 then I could easily find the answer - 8,179 misses and only 208 makes!

A few bricks

But what about those half court heaves that actually went in? Well, I counted 208 of them (remember that this data covers regular season only). Jamal Crawford is at the top of the list, with 6 - then Steph Curry and Zach Randolph with 5 each. Then Dwyane Wade, Jason Kidd and Raymond Felton with 4 each. But what about that really long shot from under the opposite basket? Who scored that and is the data correct? Well according to the data, that shot was by Vince Carter when he was playing for the Grizzlies in the 2015-16 season so let's just Google 'vince carter full court shot grizzlies' and see what we get. If you look at the video you'll see that it doesn't exactly match the data point, but still a great shot.

Not a sure thing

And what about that long diagonal almost-full-court shot from the upper left of the image above? Well that was LeBron for the Cavs in the 2006-07 season vs the Celtics, in Boston - as you can see in this clip.


Individual players

The possibilities are endless with this kind of data and mainly I've been using it to explore things that interest me - e.g. the relative decline of the mid-range shot and the games of players like Carmelo Anthony (below).

A great player!

I'll add below some more for Shaq and Yao, because these are quite interesting given the way the game has changed and moved away from the basket.








How about that Embiid, Jokic and Luka? Their charts look like this when we include all made shots in the regular season.

Joel Embiid, made shots

Jokic, made shots

Luka, made shots

The analytical possibilities are endless, and if you want to download it and aggregate it into hexes then I also have a hex layer in the folder alongside my NBA court files (I digitized all these myself).


LeBron

A very brief look at the NBA's all time leading scorer to end, not least because there are so many data points for LeBron! Over 14,000 made shots in the 20 seasons I have data for.

The King

Here are LeBron's shot charts (made shots, regular season) for his first stint at the Cavs, then the Heat, then the Cavs again and then the Lakers.

Cavs LeBron (1)

Heat LeBron

Cavs LeBron (2)

Lakers LeBron


Try it yourself

If you want to play with the data yourself then you can download it via the links in this post and if you want to have a play around with it in QGIS and aren't sure how then check out my YouTube playlist showing you how to do it. I haven't even scratched the surface here but it's so interesting, particularly if you're a basketball nerd.


You can see how much Shaq loved this!

The image above was taken in Frankfurt, Germany in 1994 (I think). I competed in the dunk contest, but lost out to someone who dunked over a life-size cut-out of Shaq. For one of my dunks I went with a dunk I saw Kenny Smith do, but the judges were very harsh.