4 Replies Latest reply on Sep 11, 2013 7:56 AM by Allan Walker

    background image x y plot - football stats

    Dan Wiltse

      Hi, I am trying to plot out the starting yard line for football plays, using the x axis, using a sample football field background image (see attached workbook). Ignore the black circles with numbers on them, those were used for something else originally.

       

      However, I can't see to get the spacing correct so that the 20 yard line is equal to x=20, and the 50 yard line corresponds to x=50, and so on.  I've tried looking at the documentation but have mostly found plotting geographic locations, so any help would be appreciated.  Thanks!

        • 1. Re: background image x y plot - football stats
          Jeff Rice

          the axis on your image (football field) starts about 12 on your x axis, and the axis on your football field is smaller than the x axis, so we need to come up with a calculation that does something similar to y=mx+b. (but not exactly)

           

          y=the visual yards on the field

          m= the multiplier

          x= the "Yard Line" Parameter

          b=12 (since the football field axis starts about 12 on the x axis)

           

           

          It gets a little more complicated since a football field goes up to 50 yards and then goes back down.  To make this work, we need to use 2 parameters, one to choose the side of field we want to calculate, and the other to choose the Yard Line.  I've attached a workbook that works on my end, but depending on the resolution and dimensions of your screen, it may only come close.

          1) create a parameter to choose Yard Line

          2) create a Parameter to choose the Side of Field

          3) create a Calculation that uses the 2 Parameters.  The Calculation will look somthing like I have below.  The 0.75 is to account for 'm' in equations

           

          if [Side of Field] =  'Left'

          then [Yard Line]*0.75+12

           

          elseif [Side of Field]= 'Right'

          then ([Yard Line]+(50-[Yard Line])*2)*0.75+12

          end

          • 2. Re: background image x y plot - football stats
            Allan Walker

            Hi Dan,

             

            So I took a different track:

             

            I used ImageJ to dump out the greyscale values from the image into a CSV.  If you need the colors back just reverse the formulae.

            Input:

            American-football-field.jpg

             

            Output: see attached. I know there is a gif to tableau converter on github if you get stuck.

            1 of 1 people found this helpful
            • 3. Re: Re: background image x y plot - football stats
              Dan Wiltse

              Thanks for the responses. I actually have the data plotted 0-100, so the opposing 20 yard line would be marked as x=80 so don't have to manage for sides of field, but like what you did to control for that.

               

              @Allan, thats really awesome how you were able to create the field, I need to learn more about how you did that.  I think my issue now is that the football field isn't evenly spaced along the x axis. If you look at the new attached workbook, you can see that the 20 yard line matches pretty close to the avg x axis of 20, but gets offline around the 40 yard line, so the rest of the markings are a little off.  Is there a way to make the yard markings match the avg x axis marks exactly? If so, I think the viz would work perfectly.

              • 4. Re: Re: background image x y plot - football stats
                Allan Walker

                Hi Dan,

                 

                Thanks for that - I didn't have time to put an x,y column in like the Image Magick script does on Github.  But it's just a case of 0 to 366 (i.e. pixel corner to corner).  I'm certainly not going to take any credit for plagiarizing an idea or the code...I just thought it was a neat way to get the image data.  I just exported using ImageJ.

                 

                The other option is to use a AutoCad DWG and then convert to a SHP file, I don't have AutoCad on my machine - and simply don't have the time right now, but that would give you pixel perfect regulation pitch dimensions.  I'm sure there are many other ways of skinning this cat.

                 

                Best Regards,


                Allan