Engine Works

Under the hood of Alteryx: tips, tricks and how-tos.
ChadM
Alteryx Alumni (Retired)

A few months ago I wrote about an experiment using TomTom’s Geocoder API.  Well, after a bit of time and a few requests, we decided to conduct a new experiment and try building out a reverse geocoder, only this time it would be specifically built for the desktop (no API involved).  What makes this so special?  In order to correctly perform a reverse geocode, a few key elements are needed.

 

The first and most important is that we need a database of point locations of addresses.  Why do we need this?  What is a reverse geocode?  We all know that a geocode is analyzing a physical address to pull geographic information, such as latitude and longitude, about that address.  A reverse geocode is the opposite, analyzing a specific point to pull the address (or nearest address, but more about that later) of that point. 

 

Because of the nature of the reverse geocode, the Alteryx Calgary databaseCalgary Join Addresses with Points is a perfect candidate for this process. 

 

Next, we need a process that quickly and easily analyzes a point to determine the address associated with that point.  Luckily, Alteryx is the best tool around for quick spatial analysis, so going that route was a no-brainer.  Using Alteryx, I was able to create a macro that utilizes a custom Addresses with Points database to create a reverse geocoding process in about an hour.  I say custom because the shipped data does not contain a Calgary Index on the Centroid field, so I re-created the database and indexed this field in order to utilize it for a Calgary spatial join.

 

The process begins with a macro.  The macro will take an incoming latitude and longitude, then create a 1 mile radius around that point using the Trade Area tool.Trade Area    From there, I pull back all addresses that fit within that 1 mile trade area, then use the Find Nearest tool Find Nearest to determine the closest address to that point.  The result is an accurate reverse geocoding macro that can be utilized in many other modules and apps.

 

That being said, there is one major item of note.  During this process, we must keep in mind that we are limited to the addresses in our database, hence the 1 mile radius.  The 1 mile radius gives us a great chance to pull back results while keeping the process quick for the user.  Just in case the user is trying to reverse geocode a rural area though, a great way to cover your bases is to create a bit of error handling (we love proper error handling!) that informs the user if there are no nearby matches.  Ultimately, if your database is robust enough, and proper error handling is implemented, a desktop reverse geocoder is not only plausible but very possible!

 

(I've also attached the macro that utilizes the TomTom Addresses with Points database if you need an example!)

 

Until next time!  

 

-Chad

For more tips, tricks, and general inquiries, follow me on Twitter! @AlteryxChad