VizWiz

Launch, grow, and unlock your career in data
Showing posts with label distance. Show all posts

May 4, 2023

Tableau Techniques for Top Notch Spatial Analytics

No comments
Looking to level up your data visualization skills? Enjoy this live stream from the April 2023 Analytics Tableau User Group (TUG) where I dive deep into spatial data analysis in Tableau!

In this session, I will walk you through the process of importing and visualizing spatial data in Tableau. You'll learn how to use advanced mapping techniques to create powerful and visually stunning visualizations that tell compelling stories with your data.

I cover everything from basic mapping to advanced geospatial analysis, so whether you're a seasoned pro or just getting started with Tableau, you'll walk away with a wealth of knowledge and practical tips you can apply to your own data analysis projects.

Don't miss this opportunity to learn from me and take your data visualization skills to the next level. Watch now and start unlocking the power of spatial data analysis in Tableau!

Download the workbook and data sources to follow along.


MEMBERSHIP PROGRAM

Join my exclusive membership program for data analytics and visualization professionals. The membership program provides unparalleled access to tutorials and templates, curated content, an online community, webinars, expert guest speakers and live training with me.

My program is the best platform to learn, grow, unlock your potential, and succeed in your career.

Sign up or express your interest @ andykriebel.com

January 25, 2022

How to Calculate the Distance Between Two Points

No comments
In this tip, I show you how to use the Distance function in Tableau to calculate the distance between two points. I also show you how to use the Makepoint and Makeline functions to draw the map. 

Download the data set to follow along here - https://data.world/vizwiz/airport-to-airport-routes

November 4, 2019

How Many Rats Are Near Hungry Cat?

No comments
Well, I don't really mean near YOU, I mean near people that live in New York. One of the fun datasets we play with at The Data School when I'm teaching them spatial analytics is Rat Sightings in New York.

And right after I taught this class to DS16, Lorna Eden posted the Workout Wednesday week 43 challenge. In this challenge, you had to find all casinos within X miles of a casino you click on. This required using the new DISTANCE function that came into Tableau 2019.3.1.

So, why not practice this technique more, but with rats? Instead of clicking on a casino, you can click on a rat to make it the Hungry Cat and find all rats within X miles of the cat. Silly, yes, and fun to practice too. The rats all have names too.

Lastly, I wanted to resize the dots based on the number of rats in the view. I used this blog post from The Data School, except I used an LOD instead of a table calc.

Enjoy! Find the rats near you.

July 9, 2018

Makeover Monday: Have volcanoes nearest to a tectonic plate erupted more recently?

No comments
Week 28 focused on volcanoes around the world and when they last erupted. Here's the original visualization:

What works well?

  • Including a description for how to interpret the chart
  • Ordering the volcanoes from front to back according to elevation above sea level
  • Coloring by the number of eruptions since 1893
  • Excellent tooltips

What could be improved?

  • Where is sea level? Some of the volcanoes are below sea level. You can't really size by negative feet below sea level.
  • There's no explanation for why some of the volcanoes have labels.
  • Make it more clear where the based of the volcano starts. I assume it's at the bottom of the viz.
  • Include reasoning for why 1893 is when the counting of the eruptions starts.

What I did

I started by creating an Alteryx workflow that took the volcanic eruptions data and plotted the volcanoes onto a 250 miles grid of the world.



I then created a custom Mapbox map on which I included the tectonic plates, which I got the boundaries for as a shapefile from sciencebase.gov, imported it into Alteryx, created points, got the lat/lon and exported as a CSV so that I could import it as a layer in Mapbox. Here's what I ended up with, which was fun to create, but not insightful at all.



I had to start all over, so this time I decided to look at how far each volcano was from the boundary of the nearest tectonic plate. Again, Alteryx to the rescue!


Once I had the data I needed, I created a few calculation to help me create a simple quadrant chart that clearly show that the nearer a volcano is to a boundary of a tectonic plate, the more recently it erupted. All of that totally makes sense given what we learned about geology in school.

October 11, 2015

Dear Data Two | Week 25: Friends

I’m starting to fall a bit behind on the postcards again, but I have a good excuse. I’ve been preparing for four upcoming talks - two in Cincinnati this coming week and two at the Tableau Conference in Vegas. Excuses behind me, I went for a simple data collection method for learning about my friends.

I had a good idea in mind for what I wanted to do and I started by looking at all of my Facebook friends, the idea being that I wanted to create a map of where they all live. Unfortunately Facebook does not make it easy to get this information. The data preparation was going to take way too long, so I opted for looking at where my college friends Facebook live.

I entered all of their names and current locations in a spreadsheet and then added a second row for each person that was the location of our college, the awesome Eckerd College in St. Petersburg, Florida. Don’t look at pictures of my college; you’ll get way too jealous.

I then took all of the locations and ran them through batch geocoder to generate lat/long values for each person. This allowed me to calculate the distance each friend has moved away since college. Duplicating the rows also allowed me to create lines connecting Eckerd College to each person.

For the postcard, there’s no way I could have drawn a dot for every person, so I aggregated some locations together and used size to represent each person or group of people. I intended to use shapes as well, as you can see on the front of the postcard, but I forgot once I got into drawing the card. Chalk another victory up for the design medium.


August 19, 2012

Tableau Tip: Create hub & spoke diagrams using the Path shelf

25 comments

I’m in constant learning mode with Tableau.  I don’t think a day has gone by when I haven’t learned something.  I love the Tableau community because everyone freely shares ideas from which they hope others borrow.  This technique of from-to patterns is no exception; it’s definitely not a new topic I’m covering here.  But I do like documenting the processes I follow, which is more or less why I started this blog in the first place.

Paths are not a feature I use often, so in my inevitable quest for all things Tableau, I decided to find some data that would provide a good learning experience.  The data for this post comes from the Bureau of Transportation Statistics.

Here’s a sample of the data. 

image


Each origin airport/destination airport combination is represented as one row in the spreadsheet. This is great, but in order to use Tableau’s Path functionality, you need to have two records for each origin/destination combination.  The first for the starting point, and the second for the ending point. 

You can accomplish this quite easily through Custom SQL.  The example below contains all the columns I need from the spreadsheet.

  • Those before the red box are inherent in the spreadsheet.
  • The SQL inside the red box is for the fields I have to add to make the paths work.
    1. You must specify the path.  In this case, 1 is the starting point, 2 the ending point.
    2. I added additional latitude and longitude fields to capture the starting and ending points.  That is, I use the origin lat/long when my path = 1 and the destination lat/long when my path = 2.
    3. I included a concatenated string for the route, which I will use on the Level of Detail shelf.
    4. Union the SQL for path 1 to itself, but change the path to 2 and change the lat/long to the destination lat/long. Notice that the Route calculation stays to same.


image


In Tableau, all you have to do is:

  1. Double-click on both Latitude and Longitude to draw the map
  2. Add Route to the Level of Detail shelf
  3. Change the Mark Type to line
  4. Add the Path Order dimension to the Path shelf


image


You now have a giant mess of lines all over the place that represent every single route in the data.  That’s all you need to do. 

The trick is that you need to write the custom SQL in order to have your data in a usable format.

I wanted to take the viz a bit farther though, so I created this interactive version on Tableau Public.


I included:

  • Filters options for Origin Airport, Destination Airport, and Airline (I chose ATL as my initial view since it’s the world’s busiest airport)
  • Colors to indicate the length of the route
  • Clicking on a color highlights the routes in the selected flight range and also highlights the destination airports on the bottom map
  • A map of the number of passengers that flew to each destination, indicated by the size of the bubble
  • Custom tooltips, which include the great-circle distance calculation


This is a pretty fun viz to interact with.  Choose all origin airports and you see all of the routes.  Choose the airport you most frequently fly from.  Choose your preferred airline.  The three New York airports are particularly interesting (EWR, LGA, JFK).

There are lots of other data elements that could be included, but I haven’t gotten to.  Think about adding options to color the bubbles and lines by things like frequency of delays, average ticket price, etc.

Wouldn’t this be really cool to do with your friend networks on Facebook?  Oh wait, we did that in a recent hack-a-thon.

January 5, 2012

Tableau Tip: Calculating the distance between two points

5 comments
I’m working on a project that requires me to calculate the distance between stores in order to plan resource allocation.  Pretty cool stuff that could have a huge impact if it pans out.
Naturally I want to do this in Tableau, but I since I hadn’t done this before I turned to the Tableau Forum and found this great step-by-step tutorial

TIP: For those of you that may be new to Tableau, I would highly recommend that you use the forum if you’re approaching something you’ve never done before.  You’ll often find that someone has already done something similar and it’ll save you a lot of time versus re-inventing the work yourself.

Tableau has outlined this as a 22 step process, but they go through it in extreme detail.  Note that your data source MUST have latitude and longitude available in this example.  Here’s a slimmed down version for you (some of this is taken directly from the article):
  1. Connect to your data source, select Single Table, then select Custom SQL
  2. Create an inner join on a second instance of the table where the locations from the two instances are not equal (refer to the SQL script in the detailed instructions)
  3. Click OK, then Extract the data.  For me, I’m looking at 7271 stores, so the self join will result in about 50M records.  Leverage the power of Tableau’s data extracts!
  4. Double-click your latitude and longitude fields to start building the map.  You may need to set the geographic role of the fields if you don’t have them named Latitude and Longitude.
  5. Use the Great Circle Distance formula by creating a calculated field named Distance (or the name of your choice)

    The formula is:
    3959 * ACOS
    (
    SIN(RADIANS([Lat])) * SIN(RADIANS([Lat2])) +
    COS(RADIANS([Lat])) * COS(RADIANS([Lat2])) * COS(RADIANS([Long2]) - RADIANS([Long]))
    )

    NOTE: To calculate miles, use 3959 as the first number.  For kilometers, use 6371 as the first number (thanks to Shawn Wallwork for the comment)

     
  6. On the Marks card, in the list, select Line. This will create lines between all locations on the map.  Start with only a couple locations if you have a huge dataset, otherwise it could take some time to draw all of the lines.

From this point, you can perform tons of different analysis.  One example would be to drag Distance onto the Color shelf and the Label shelf on the Marks card to color code and label the distances between each point on the map. 

Think about how you could blend other data source.  For me, I might have home zip codes for employees in another data source and I want to see all stores within a certain radius of each employee.  The possibilities are almost endless! 

You can find a sample workbook for how all of this is done here.  I know I’ll be using this technique over and over again.