Alteryx 101: How to Spatial Analytics

by William Guicheney

Hello, everyone!

After a jam-packed week at the Data School focused primarily on Tableau and the theory behind predictive analytics, my cohort mates and I are spending the evening putting the final touches on the workflows and dashboards we will be presenting to the rest of the team tomorrow. Andy assigned each of the DSers a topic or theme and asked us to provide a summary of key insights to the rest of the class in an effort to both allow us to review content we found difficult, and to give us a taste of what teaching this stuff is like! As you can guess from the title of this blog post, I was given the responsibility of building a presentation around spatial analytics in Alteryx.

With that in mind, let’s explore some of the powerful tools Alteryx has in store for us to allow us to get the most insights out of our spatial data. And boy, do I have one heck of user case for you today. As a trainee consulting analyst, I am highly versed and trained in all business-related questions and matters. Therefore, I know – as any of you business-savvy readers will too – that one source of catastrophic business risk trumps all other: meteorite strikes. I know just reading this has gotten the sweat running on the back of your neck as you may have realized that you haven’t adequately planned for the impending doom that these flaming rocks from space represent for your business, but have no fear, Alteryx is here. The objective of our analysis will be to identify which cities are more at risk of being completely destroyed by asteroids and should therefore never be on our investment radar. To do so, we will be utilizing four tools: Create PointsTrade Area, Find Nearest and Spatial Match.

  

Our analysis itself will be divided into two parts:

  • First, we will identify which cities were closest to past meteorite hits,
  • Secondly, we will identify which city area’s have suffered the highest number of meteorite strikes in the past.

We will be using two publicly available datasets to perform our analysis: one on meteorite landing data, and a world cities database. The former includes a range of information on the locations where meteorites fell, their mass, etc. while the other includes data on the localization of cities, their population, etc.

 

Step 1: Finding the meteorite crater closest to each city

In this step, we will be transforming our lat/long data from each dataset into spatial objects that we can use to find each city’s closest meteorite crater. This will be essential information for our business, as we know that a meteorite never hits the same spot twice! Ha!

  • First, you’re going to use a Create Point tool to convert your lat/long data into a spatial object, called a centroid. This will convert the coordinates into a single point that we can later use to run some more spatial analytics. Just drag your input data to the tool, select the appropriate lat and long fields, and you’re all set to start!

  • Secondly, you’re going to connect each of your Create Point tools to the Find Nearest tool. This tool will automatically calculate the distance between each centroid from one dataset with the centroids from the other, and return two columns: one that tells you which centroid is the nearest to each of your target centroids, and another with the distance between those two centroids.

  • You’re almost there. After this step, you are probably going to want to use some FormulaData Cleansing, or Select tools to finish preparing your dataset for analysis. After cleaning mine up a bit, I get the output below! In a few steps, you calculated the distance from each city to the nearest meteorite crater, and can now tell your boss to move all his factories to Baruu Urt in Mongolia!

 

Step 2: Finding the total number of meteorites that fell in each city’s area

In this second step, we are going to be building a danger zone around each city and finding the number of meteorite craters that are located within them. This is a little bit more complicated than before, so pay attention! Tens of thousands of lives may depend on it.

  • First, we are going to use the Trade Area tool to build a radii polygon – also known as a filled circle – around each city. All you are going to want to do is connect your city’s Create Points tool with the Trade Area Tool and select the radius and units that fit your needs. Mine will have a radius of 20-miles – I know that’s huge but better safe than sorry right?

  • Secondly, we are going to use the Spatial Match function to find how many of our meteorite strikes fall within each of the trade zones a.k.a. “danger zones” we just built. In order to do so, you are going to want to connect the Trade Area tool to the target (or T) node of theSpatial Match tool, and the meteorite data’s Create Points to the universe (or U) node. In the configuration window, make you sure you select your trade area spatial object on the target’s Spatial Object Field! This tool is also a good opportunity to remove some unnecessary fields and change the data types of some of your variables.

  • Almost there! Now that we know whether the meteorites fall within the radius around each city, we simply need to count them up. To do this, I am going to use the Summarize tool which is also geared towards aggregating spatial data. There are a few things to keep in mind here:
    • Make sure you’ve set your fields to the right data type so you can aggregate them in the way you’d like to: I had to convert my mass field to double in order to average it out.
    • Make sure you select the correct spatial object type when you add them. For the trade areas, you are going to want to click AddSpatial, and Create Convex Hull, whereas for the meteorite craters you will select Create Centroid.
    • By summarizing the data, you are losing some of the finesse and granularity of your data, which might be a problem further on in your analysis.

  • Afer that’s done, I am just going to add a Sort tool to easily identify which cities are the most likely to be removed from the map by a giant flaming stone. Here’s what my final output looks like. As you can see, Eldama Ravine is by far the riskiest place to do any business whatsoever, unless you’ve got amazing space debris insurance!

If you’d like a complete guide what your workflow should look like after completing all these steps, check out the picture below. Who would’ve thought that you could accurately measure the risk that meteorites present for your business with just a few tools? Unbelievable!

 

Thank you for tuning in, I hope you’ve found this guide interesting!

See you next week for more data madness

 

 

 

 

Avatar

William Guicheney

Tableau Server Hardening: Simple tips to keep your server safe

6 mins read

Fri 18 Aug 2017

Dashboard Week Day 5: Climate Change and the Finale!

5 mins read

Sun 13 Aug 2017

Dashboard Week Day 4: Hot Dogs, Batch Macros, and Parameters

5 mins read

Fri 11 Aug 2017

Dashboard Week Day 3: APIs and Public Transit Data

6 mins read

Wed 09 Aug 2017