Torvaney / ggsoccer

Plot soccer event data in R/ggplot2
https://torvaney.github.io/ggsoccer/
Other
180 stars 27 forks source link

Additional data sources by default #15

Open Torvaney opened 4 years ago

Torvaney commented 4 years ago
huffyhenry commented 4 years ago

Tracab uses centimetres and not synthetic units. The actual pitch length and width are specified in the metadata. The other dimensions (penalty box width, etc.) are not provided. And to confuse the matters further, Tracab files are in my experience often distributed without metadata.

In light of this, it seems to me that support for Tracab should be a method that constructs pitch_tracab from width and length (with the usual 105x68 defaults). The missing dimensions should be probably taken from the standard pitch? Goal sizes certainly are fixed, and getting the rest correct is simply impossible without extra information.

In summary, I propose this design:

make_pitch_tracab <- function(length=105, width=68){
    list(
        length=100.0*length,
        width=100.0*width,
        origin_x=-50.0*length,
        origin_y=-50.0*width,
        goal_width=732.0,
        ...
    )
}

pitch_tracab <- make_pitch_tracab()

If this makes sense to you, I can send a PR in the next few days.

Torvaney commented 4 years ago

Yep - that sounds fantastic!

Thanks