community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx Knowledge Base

Definitive answers from Designer experts.

Create a Map Book with Spatial Clustering

Alteryx
Alteryx
Created on

Map Input.PNGGeneric test data for demonstrating the process

One of the perennial challenges of creating high-quality maps is working with data sets where the spatial data is too spread out to make a useful map. The general solution for this challenge is to create a Map Book. A Map Book is a series of maps that show a subset of the data at a more detailed resolution. To create a Map Book in Alteryx, we bring our data into the Report Map tool with a Grouping Field, which will allow the tool to create a separate map for each group. 

 

What happens when there is no grouping field in the data, or the grouping field does not group spatially?

 

Well, we have to create a spatial grouping field.

 

To do this, we'll dip into the Predictive Grouping toolset and use the K-Centroids Cluster Analysis tool combined with the Append Cluster tool to dynamically create a number of clusters based on their Latitude and Longitude. This is set up as below:

 

 Workflow Clustering Focus.PNGThe workflow level view of creating spatial clustersIn this example the data are saved as spatial points. To perform cluster analysis we need to have Latitude and Longitude as separate numeric columns, so we use the Spatial Info tool to get the Lat/Long. The K-Centroids Cluster Analysis tool is the key to this workflow. In the configuration of the K-Centroids Cluster Analysis tool, we will use only the Lat/Long fields (in this case they are labeled as CentroidX and CentroidY because of the Spatial Info tool) as the selected Fields for cluster analysis. Using K-Means as the clustering method is appropriate for this use case, as it will create clusters based on the euclidian distance between points. There will be some adjustment required on the Number of Clusters setting, but this can be done automatically with an Iterative Macro (stretch goals!). 

Cluster Assignment.PNGCluster ID's are joined to the data

Once we connect the Append Cluster tool and run the workflow, cluster labels generated by the K-Centroids Cluster Analysis Tool are added to our data stream, giving each row a group number. These clusters are now available for use in the Report Map tool.  ProTip: When using the Report Map tool it is hugely helpful to rename your inputs. This is because the name of the input is populated in the tool's configuration. Knowing the name of the input makes it easy to know which layer you are working with. You can rename your input by clicking on the text that populates in the connection between your data stream and the Report Map Tool (by default the name is typically the number of the connection, e.g., "#1")

 

Report Tool Input.PNGRename your inputs!

 Now, you can use the Cluster Field as your Grouping Field in your Report Map Tool!

 

Map Report Input.pngNow the grouping field is Spatial!

 

Taking it Further 

 

If you want to control your extent separately from your data layers, you can create an extent polygon and use that as your zoom and grouping layer. This takes a couple of extra tools and a slightly different configuration in the Report Map tool.

 

We create the clusters the same way as before, but this time, we add the Poly-Build tool and create a Convex Hull polygon using the Cluster as the Group Field. Then we can use the Spatial Info tool again to get the Bounding Rectangle as a Polygon which we can Buffer to get a little bit of space around the points.

Extent Workflow.PNGCreate your own dynamic extent featureNow you have your own extent feature.

 Extents.PNGThe odd shapes are the Convex Hull polygons, and the squares are the Extent polygons ready for use in the Report Map toolWe can finish this up by bringing the polygons into the report map tool. The changes that need to be made are as follows: In the Settings, change the Expand Extent to 0% because that's being done with the Buffer tool. Under Data, we can remove Grouping on every layer except for the Extent layer. In the Layers tab, we make sure that we're Zooming to the Extent Layer only and Setting it's opacity to 0 (we don't need to see it).  We also un-check Show in Legend.

 

Now you have two methods to dynamically create Map Books with Alteryx!

 

For more information please see the following articles or check out the attached workflow:

Tool Mastery | K-Centroids Cluster Analysis

Tool Mastery | Report Map

Comments
Alteryx Certified Partner
Alteryx Certified Partner

As a GIS Professional, I love this!  Great work, and awesome way to utilize the K-Centroids Cluster Analysis and the Append Cluster tools!

 

@Deanna