Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

soccerShotmap plotted as mirror image #15

Closed
TimHoare opened this issue Nov 21, 2018 · 1 comment
Closed

soccerShotmap plotted as mirror image #15

TimHoare opened this issue Nov 21, 2018 · 1 comment

Comments

@TimHoare
Copy link
Contributor

When I plot an xG map using soccerShotmap, the locations are appearing as a mirror image as where they should be. I used soccerTransform to adjust the coordinates an all Statsbomb data which fixed a similar issue for soccerPassmap however this seems to have created a new issue for the shot map. Should I be using the normal Statsbomb coordinates in this case (i.e. should I not have used soccerTransform here) or is it an unrelated issue do you think?

Thanks

@JoGall
Copy link
Owner

JoGall commented Nov 21, 2018

StatsBomb reports their x,y-coordinates for both teams as if attacking from left to right, so the shots won't always be the orientation they appeared from the camera angle (i.e. they will appear mirror imaged when a team was attacking from right to left).

If you want to mirror the locations for plotting you could just subtract the y-coordinates from the y maximum (120 if raw StatsBomb coordinates, whatever your widthPitch is if coordinates are transformed). e.g.:

# raw data from StatsBombR (1 < x < 120, 1 < y < 80)
fawsl_dat <- d %>% 
  filter(match_id == 19746)

# mirror y-coords
dat <- dat %>% 
  mutate(location.y = 80 - location.y)

# transform from StatsBomb x,y-coords to metre units
dat <- dat %>% 
  soccerTransform(method = "statsbomb")

# plot shotmap
dat %>% 
  filter(team.id == 967) %>% 
  soccerShotmap()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants