## Curved Lines in Tableau through Data Densification

I read a couple of inspirational blogs recently:

These both discussed the use of domain padding and data densification to extrapolate or fill-in on data that is not included in the data source. Bora’s application of this capability to interpolating curves inspired me to revisit a workbook I had made a couple of years ago showing mobile tower transmitters. At the time I simply triple-read the input data using a UNION and I ended up with triangles showing the sectors:

What I had really wanted was curved sector arcs but I couldn’t scale the solution to produce a smooth curve. Applying Bora’s technique I was able to rectify this easily and plot with as many interpolated points as I want using only two passes over the data:

See these workbooks for the before/after approaches.

Mobile Towers – orig.twbx

Mobile Towers – new.twbx

This then got me thinking about other applications this technique could be used for and the first “curved line” solution that came to mind was plotting great circle routes on maps. I’ve been asked if Tableau could do this in the past and the answer was no, but using this approach I produced the following:

I densified the data to produce points for interpolation and then passed the data into R. There I used the gcIntermediate function to generate the intermediate lat/long points and plotted the resulting line. See this workbook for the solution.

Great Circle Routes.twbx

I think this same technique could be used for a number of other interesting applications such as Sankey diagrams. Hopefully you find it useful.

Hi. I'm Alan. By day I manage the APAC sales engineering team for Snowflake Computing. By night, I'm a caped crusader. Or sleeping. Most often it's sleeping.
This entry was posted in Uncategorized. Bookmark the permalink.

### 10 Responses to Curved Lines in Tableau through Data Densification

1. Can you please check the Mobile Towers – orig.twbx and Mobile Towers – new.twbx workbooks? When I try to open them I get “An unexpected error occurred opening the packaged workbook.”

• It works fine for me. What’s the error when you click the “show details” button?

2. Allan Orbigo says:

Hi Alan, I tried to replicate the mobile tower map and I was able to until today. I’m doing the same approach but for some reason nothing shows up on the map. Can you provide a step by step process on how you plot the mobile tower sectors?

• Hi Allan,

Sure – check out this workbook that shows it step by step. Hope this helps.
https://www.dropbox.com/s/4hwtmevw5y2gnbf/Mobile%20Towers%20-%20V3.twbx?dl=0

Note this is using a new technique that doesn’t require custom SQL and multiple passes over the data, so it’s much more performant. Most of the logic is the same – just how we create the PointID is different from the previous workbook I posted before I knew better (and had LOD expressions to help).

Cheers,
Alan

• Allan Orbigo says:

Hi Alan, thanks for the quick reply. I tried this approach but I got stuck in the plot-long calculated field. For some odd reason it doesn’t spit out the right value. It’s calculating just barely above zero instead of around -120 for my sample data. Any idea? Thanks

3. Allan Orbigo says:

Hi Alan, I figure out now what is the issue with my twbx. For some odd reason the LOD using MAX in Lon calculated field returns a single value of zero. I changed the MAX to MIN and it seems to work. It must be because of my longitude values being negatives. Still it doesn’t make sense to me as I assume it will compare the values within the same sectorname. Thanks again for the help.

• Yeah – I think I was a bit careless in my logic. I changed the calcs so they now handle both + and – values for lat and lon. Have a look at the revised workbook (same dropbox link).