1 2 3 4 Previous Next 56 Replies Latest reply on Jun 4, 2018 4:00 AM by Yuriy Fal

    Curved Lines - Never Ending Story

    Bas Groothedde

      Hi everyone,

       

      I am sorry to once again bother you with curved lines. In the discussion (Curved Lines on a Map ) a lot

      of possibilities are discussed, however all of them need additional programs. I wonder

      whether there is a way to create curved lines (flight paths) without using Alteryx,

      Urban Mapping or R. Except for R, as far as I know, all programs are with costs.

      And learning R would cost to much time for what I need.
      Looking forward to your answer!


      Cheers!

        • 1. Re: Curved Lines - Never Ending Story
          Łukasz Majewski

          Yes, we can!

           

          Here is data:

           

          and here is the magic:

          You can adjust the number of midpoints with the slider.

           

          Cheers,

          Łukasz

          6 of 6 people found this helpful
          • 2. Re: Curved Lines - Never Ending Story
            Bas Groothedde

            Thanks Lukasz!
            Great work!

            • 3. Re: Curved Lines - Never Ending Story
              Łukasz Majewski

              Thanks - it was fun to work on this.

              I took the trigonometry formulae from this site: Aviation Formulary V1.46

              Now I started thinking of ways to optimize the algorithm so that the number of mid points is not fixed but spread along the line so that it is more dense where bent more or close to the pole. Also a couple of special cases like antipodean routes need to be taken care of.

              Anyway this simple example proves the point, right?

              2 of 2 people found this helpful
              • 4. Re: Curved Lines - Never Ending Story
                Bas Groothedde

                Hey Lukasz,

                 

                I appreciate meeting people in the forum that are as enthusiastic about Tableau as I am . Unfortunately it will take some time until I get as far as your are.
                Anyways, I have more theoretic questions left. I have seen a similar approach with making Bezier Curves for jumpplots.
                You have to define a starting (window_min...) and an ending (window_max....) point. And the you define the number of points in the line. Point is used to define whether one is dealing

                with a point on the curve or a starting or ending point. Is this correct?
                Furthermore I would like to ask how the window function works on the strings. Window functions take, in this case, either the minimum or the maximum of the list 'city', of which you take

                the min or max again. What effect does this have?
                Are the shapes of the lines made arbitrarily?
                Yeah we should think on an algorithm! Using other programs in order to get proper curved lines should be unnecessary!


                I agree: You proved it. Thanks a lot!
                Especially, thank you for taking the time!

                • 5. Re: Curved Lines - Never Ending Story
                  Bas Groothedde

                  Sorry to bother you again Lukasz,

                  I have tried to use my own data and for some reason i cannot get the curve done .
                  I used your file and I have added a sheet called "different data".

                  Would be cool if you could help me here!

                  Kind regards!

                  • 6. Re: Curved Lines - Never Ending Story
                    Łukasz Majewski

                    You have to replace original Lat/Lon fields with the calculated ones - see the attachment. You were missing [Point (bin)] dimension from the dual axis so I removed it.I think I managed to use your data answering your other question

                    I will share a verbose explanation of my method later today.

                    1 of 1 people found this helpful
                    • 7. Re: Curved Lines - Never Ending Story
                      Bas Groothedde

                      Thanks,

                      but i am not sure whether it is entirely correct. Changing the parameter midpoint does not change the bent of the paths but the lengths. Great Lukasz looking forward to it.
                      I have seen your other answer. Just checking it. I'll make sure that you get your credit !!!!!!!!
                      Keep it up!

                      • 8. Re: Curved Lines - Never Ending Story
                        Łukasz Majewski

                        Sorry - I forgot to show missing values.

                        republished corrected version now

                        1 of 1 people found this helpful
                        • 9. Re: Curved Lines - Never Ending Story
                          Bas Groothedde

                          This is great  Cool Lukasz, you are very helpful!

                          • 10. Re: Curved Lines - Never Ending Story
                            Łukasz Majewski

                            [Edit] Please go to this post for a more efficient method

                             

                            The promised explanation of what I did to produce the arcs:

                             

                            1. In order to have tableau draw a line on map we need two records corresponding to two different points given by latitude and longitude. Those 2 records distinguished by [Path] field are the key element because having 2 records we may create an arbitrary number of marks in tableau using so called 'domain padding'. Check out 'Domain Padding' presentation in TDT space: The specified item was not found. for more information on the topic. The point is to use a 'range aware' field - so either date or a bin - and show the missing values. I used bins so first needed a numerical dimension ranging from say 0 to the selected number:

                             

                            [Point]

                            IF Path = {MIN([Path])} THEN 0 ELSE [Mid Points] END
                            

                             

                            the above makes use of a LoD expression but it might as well be something like:

                             

                            IF Path = 'City A' THEN 0 ELSE [Mid Points] END
                            

                             

                            The point is to have those values as dimensions as we will address a table calculation to the derived bin:

                             

                            2. In order to have the domain paddedd with values ranging from 0 to [Mid Points] we have to switch on 'Show Missing Values' option. Although we want the [Point (bin)] field in the detail shelf we have to (?) first place it on rows or columns only to switch it on and then move it to the Marks:

                             

                            When we switched on 'Show missing values' the number of marks was multipled by the selected value of [Mid Points] parameter from 12 to 6006 if we choose to have 1000 mid points. As soon as we move the pill to the marks shelf it changed back to 12. Don't worry - the 'Show Missing Values' option is still set and it will manifest itself when we address any table calculation (e.g. index()) to the [Point (bin)] dimension.

                             

                            3. The table calculation is utilized in the new latitude/longitude fields. As first step the following four calculations are required for every line/path:

                             

                            [Lat1]:

                            WINDOW_MIN(MIN(IF [Path]= {MIN(Path)} THEN [Latitude] END))
                            

                             

                            [Lat2]:

                            WINDOW_MIN(MAX(IF [Path]= {MAX(Path)} THEN [Latitude] END))
                            

                             

                            [Lon1]

                            WINDOW_MIN(MIN(IF [Path]= {MIN(Path)} THEN [Longitude] END))
                            

                             

                            [Lon2]

                            WINDOW_MIN(MIN(IF [Path]= {MAX(Path)} THEN [Longitude] END))
                            

                             

                            Thus we will have geographic locations defined for all the points - including those showed as missing - as WINDOW_MIN will switch on domain padding when addressed to compute using [Point (bin)].

                             

                            Then we can calculate the remaining bits:

                             

                            [Distance] between City A and City B

                            //http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates
                            ACOS(SIN(RADIANS([Lat1]))*SIN(RADIANS([Lat2]))+COS(RADIANS([Lat1]))*COS(RADIANS([Lat2]))*COS(RADIANS([Lon1])-RADIANS([Lon2])))
                            

                             

                            followed by a few other transformations taken from the aforementioned website, namely:

                            the [index] field is defined as index()-1 so that it can be used to calculate the fraction f of the full distance as:

                            [index]/([Mid Points]
                            

                            and all the calculations I grouped as "Intermediate Points" produce the consecutive coordinates between the two original points which lie along the shortest path and spread uniformly.

                             

                            4. Finally all we need to do is to put the right pills in the right place and address our new longitude & latitude properly. In fact we just need the [N] field which I used to number individual paths and [Point (bin)] in the marks (detail) shelf. [The Latitude] & [The Longitude] go to rows & columns:

                            and last but not least - in this set up - they are addressed to compute using [Point (bin)]

                             

                            That's it.

                            6 of 6 people found this helpful
                            • 11. Re: Curved Lines - Never Ending Story
                              Bas Groothedde

                              Lukasz,
                              This is fantastic! I would give you 1000 points for that, if I could
                              Thanks to people like you I finally learn how Tableau works!
                              Thanks for the explanation!

                              • 12. Re: Curved Lines - Never Ending Story
                                sarah.parrott

                                Is there a more in-depth. descriptive, and straight-forward tutorial for this type of work? I'm new to tableau and to be honest this does nothing but confuse me, especially with the lack of explanation for things. I need my paths curved because my paths are literally covering another origin city's coordinates. I've downloaded your file, copied it, and followed your instructions word for word and have been working on this for about 8 hours and I'm still at square one and I'm not computer-illiterate by any means.

                                • 13. Re: Curved Lines - Never Ending Story
                                  Łukasz Majewski

                                  Hi Sarah,

                                   

                                  Tableau will not enable drawing curved lines out of the box. My approach is the only work around I am aware of and yes it is rather tricky especially if you are new to the tool.

                                  Please share your packaged workbook or at least a sample of your raw data and I should be able to help.

                                  1 of 1 people found this helpful
                                  • 14. Re: Curved Lines - Never Ending Story
                                    sarah.parrott

                                    Oh my goodness I literally JUST figured it out! It was a coding error on my part in the Lat1/Lat2/Lon1/Lon2 equations(Instead of putting [path order] in the beginning of the IF statement, I was leaving it as "Path" and only changing the Min/Max statement to [path order].)

                                     

                                    Thanks for offering to help! That was so nice of you, I was really frustrated that it wasn't working. It's funny how one silly little error will mess everything up!

                                    1 2 3 4 Previous Next