oshimamh / nbaProj

nbaProj
1 stars 0 forks source link

plotting a matrix. #3

Open oshimamh opened 8 years ago

oshimamh commented 8 years ago

I'm still trying to figure out how to work with the bin matrix for shot locations.

klay <- getShotData("Klay Thompson")
shots = SpatialPoints(coords = klay[ , c('LOC_X', 'LOC_Y')])
x = GridTopology(c(0,0), c(5,5), c(100,94))
court = SpatialGrid(x)
bins = over(court, shots)
binMat = matrix(bins, 100, 94)
image(binMat)

The goal with this is to create 5 x 5 bins for the shot data. the range of the shot data is about -250 to 250 on the x axis and -50 to 420 on the y.

The plot that image(binMat) returns kind of works but I'm not sure how to better visualize this.

dmcglinn commented 8 years ago

I worked on this for a little bit it boils down to the fact that you're getting the spatial geometry wrong. It appears that the dimensions of the coordinates are in inches so I would suggest defining 1 ft x 1 ft cells and I would define the court accordingly.

dmcglinn commented 8 years ago

oh and image(binMat) is working its just that the values within binMat are not quite correct