Extracting Latitude And Longitude From A KML File Using Alteryx

Blog | April 18, 2018 | By Vijai Narasimha

Geospatial Analysis Unleashed: Extracting Latitude and Longitude from KML Files in Alteryx

Alteryx Tips and Tricks: Mastering Geospatial Analysis with KML File Processing

Unlocking Location Insights: Extracting Latitude and Longitude from KML Files Using Alteryx

As discussed in one of the previous blog, Geo mapping is a very powerful technique in studying the topography and understanding the geographic locations better with the existing data.

With Tableau’s instant geocoding, it is very easy to build visually rich interactive maps for fields that have a specified geographic role.

For most of the developers, Geo Spatial data for geo mapping is a big requirement. Spatial data sets offer something that regular fields on Tableau cannot offer. For example – Lines and Polygons. These cannot be automatically shown on Tableau without the support of Point Oder, Path Information and Polygon data.

With Tableau 10.2, a new native spatial data connector was introduced. Most of the developers had a big sigh of relief as it made their jobs a little easy. The Spatial connector can be used to access KML files, ESRI Shape files, Map-Info tables and GeoJSON files.

Understanding KML Files and Their Role in Geospatial Analysis

Extracting Latitude and Longitude: Advanced Techniques in Alteryx

Leveraging Alteryx for Efficient Geospatial Data Processing

Optimizing Geospatial Analysis: Best Practices in Alteryx for Latitude and Longitude Extraction

In the afore-mentioned blog, we had created 3 different layers with Points, Lines and Polygons using Google Maps.

Tableau at this point (10.5) will not be able to represent Points and Lines and Polygons together. We may expect them in the near future.

This error forced us to bring three separate files and plot them on individual worksheets and assemble on a Dashboard.

To show points and lines and polygons together, we need to extract the Latitude and Longitude. In this blog, we will be discussing the next steps of extracting Latitude and Longitude in Alteryx after the KML file is created using Google maps. After the Latitude and Longitude fields are created, we can plot all of the points together.

For this blog we will be focusing on Spatial Analysis Tool Palette on Alteryx. Though we need only a couple of tools for this example, Spatial tools have a wide variety of applications. If the Spatial tools are not available, we need to enable them as part of the tool palette.

__________________________________________________________________________________________________

The Spatial tools on Alteryx offer variety of features like Creation of spatial points, Finding closest points, Distance evaluation, Drive time, Grid analysis, Splitting spatial objects, Spatial properties, Trade area to name a few. Alteryx developers use most of these tools on daily basis when a geo data is applicable. For this blog, we will be using Poly-Split and Spatial Info tools.

First, we need to study the KML file that was created in the other blog that consists all the 3 layers: Points, Lines and Polygons.

Though it is a KML file type, the data is stored in XML format. If we open this file on notepad like application, we can see the following features:

a) Basic file properties like file type, name, description, image properties etc.

b) All the Layers that we have created are stored within the respective Folders. The folders show the type of object created and the individual coordinates. Also each folder can have multiple types of geometry i.e. a single layer can have Points and Lines and Polygons. But these coordinates are not visible on Tableau as Tableau treats them as Geometry aggregation field.

Harnessing Alteryx for Geospatial Insights: Strategies for Success

Advanced Techniques: Enhancing Geospatial Analysis with Alteryx

Streamlining Data Processing: Alteryx Tips for Latitude and Longitude Extraction

Empowering Location-Based Decision-Making: Geospatial Analysis with Alteryx

Now the task is to extract these individual X and Y coordinates. This will give us the flexibility of filtering unwanted data points or unwanted layers.

Now we shall build a very simple workflow in Alteryx and output the data into a Tableau readable flat format.

1) Input data as a KML file.

We don’t have to specify any other properties. Alteryx automatically reads it as a KML file and identifies the Spatial objects. The description column is empty as nothing was provided when the KML file was created.

2) Next, we need to split the Lines and Polygons into individual data points. The Point spatial object will be as is as they are individual points themselves. We need a Poly-Split tool to identify the underlying points. If we add a Browse tool, we can see the details. The first data point is a 0 because it is providing an Index ID starting from 0 and increments for each row of the Line and Polygon.

3) Now, each of the Split_SpatialObj has a coordinate. We need a Spatial Info tool to identify the X and Y values. For this example, Centroid and End Points have the same values.

4) We need some clean up. Rename some fields, remove unwanted fields.

5) Write the data into a file for Tableau.

6) Input data into Tableau. Now we have Point Order and Latitude & Longitude. If Tableau does not provide the Geographic role, we need to specify for the mapping feature. Convert into a Line chart and the Point Order field is used on the Path card on the Marks shelf as a Dimension.  The Name field is used either on Color or Label or Detail.

We can notice that this is no longer a Spatial file. It is read as a CSV file.

Now all the values are plotted in one sheet.

Some more examples:

About the Author
A BI Analyst and Tableau trainer working for USEReady since 2015. Well versed in Data Analysis, ETL and Dashboard building across different business domains.
Vijai NarasimhaSenior Business Intelligence Analyst | USEReady