Continue to the first and second parts of the Spatial Analytics in Alteryx series, I am going to write the last part about Spatial tools. In the first part, I introduced 3 main Spatial Objects, and how to create each type of Spatial Object in Alteryx. In the second part, I shared how to find the distance between 2 points or from one Point Object to another Line, a Polygon Object, find the nearest distance, and how to combine and cut 2 Polygon Objects.
In this last part, I am going to share about finding the relationship between 2 Spatial Objects. For example: counting how many stores are in a specific area. In that case, I will use the Spatial Match tool in Alteryx. There are many more features of that tool. Let's figure it out with me in this blog!
1/ Where Target Intersects Universe
2/ Where Target Contains Universe
3/ Where Target Within Universe
4/ Where Target Touches Universe
5/ Where Target Touches or Intersects Universe
6/ Where Target Bounding Rectangle Overlaps Universe
To get started, I used 2 datasets for the demo. The first dataset is for the spatial Polygon data from the U.S. National Weather Service at https://www.weather.gov/gis/USStates. The second dataset is the dataset of the U.S. University data from HIFLD Open Data at https://hifld-geoplatform.opendata.arcgis.com/datasets/colleges-and-universities/explore.
I imported those 2 datasets into Alteryx Designer and used the Browse tool to show the map (Image 1). Then, I can use the Select tool to remove some unnecessary columns.
1/ Where Target Intersects Universe
If you choose this option, Alteryx will return the match records of 2 Spatial Objects.
I drag the Spatial Match tool from the Spatial Match tool from the Spatial palette. to connect with other tools. According to the Alteryx Help page:
- If you are working with both Polygon objects, the larger Polygon Object should connect to the Target anchor (T). The smaller one will connect to the Universe anchor (U).
- If you are working with Polygon Objects and Point Objects, then you need to connect the Polygon Objects to the Target anchor (T). The Point Objects will connect to the Universe anchor (U).
Therefore, I connect the Polygon Objects (U.S. States) branch to the T input anchor and connect the Point Objects (U.S. University) branch to the U input anchor. In the Configuration window, I choose the Polygon Objects for the T input and Point Objects for the U input. In the drop-down menu below, I choose Where Target Intersects Universe.
Below the drop-down menu, there is a checkbox to Output Intersection Object (Intersects Only). If you check that box, there is a new column to output only Intersection Object. If you don't check that box, the result will return the match records between 2 specified Spatial Objects.
There are many data points from 2 datasets, so I used the Filter tool to filter only California State by connecting it to the Match output anchor (M).
In Image 4, the result returns the CA Polygon objects (red area) and University Point Objects (green dots). From the result window, you know that there are 718 universities and colleges in California from 2 datasets.
2/ Where Target Contains Universe
If you choose this option, the result will return the match records if the Universe Objects are inside the Target Objects (Image 5).
I change the option from the drop-down menu to Where Target Contains Universe. I got the same result (718 University or Colleges in CA) as the previous part because the Point Objects were inside the Polygon Objects (Image 6).
Note that, if Target contains the Universe, Target will intersect the Universe. However, if Target intersects the Universe, we are not sure Target can contain the Universe.
3/ Where Target Within Universe
Opposite to the previous option, the result will return the match record if the Target is within the Universe (Image 7).
In the Configuration window, I only change the drop-down menu option to Where Target contains Universe. Our Target is Polygon Objects and the Universe is Point Objects. The Target cannot be within the Universe, so the result returns 0 records (Image 8).
4/ Where Target Touches Universe
For this option, the result will return the match records if the Target Object boundary touches the Universe Object boundary (Image 9.
To demo this case, I only use the U.S. States dataset. Then, I used the Filter tool to filter only CA State. I connect the True output anchor from the Filter tool to the Target input anchor (T) and the False output anchor to the Universe input anchor (U). It means that I would like to find which States share the border with California.
In the Configuration window, I choose Target touches Universe. The result will return 3 records. So there are 3 U.S. States (green color) that share the border (brown color) with CA (Image 10).
5/ Where Target Touches or Intersects Universe
This option will combine both option 1 and option 4. The result will return the match records if the Target touches or intersects the Universe (Image 11).
6/ Where Target Bounding Rectangle Overlaps Universe
For this option, Alteryx will create a rectangle boundary outside the Object. If the boundary of one Spatial Object touches or intersects other boundaries of a Spatial Object, then the result will return the match records (Image 12).
To demo this, I also keep the same workflow as part 4 above. However, I changed the option to Where Target Bounding Rectangle Overlaps Universe. There is a new record appeared in the result window. That is Idaho (ID). (Image 13)
If you look at the map, California and Idaho do not share the same border. But when I choose the option Where the Target Bounding Rectangle Overlaps Universe, the boundary of CA intersects the boundary of ID. In Image 13, I draw the boundary of each state in orange color, so you can see they intersect/overlap.
In the last part of Spatial Analytics in Alteryx, I shared the features of the Spatial Match tool. The Spatial Match tool is very helpful if you would like to know the intersection area or which Spatial objects contain/touch/intersect/ within other Spatial objects. There are many other Spatial tools in Alteryx that I haven't mentioned such as Spatial Info, Smooth, Poly-Split, etc. I believe you can easily use those tools, so I only mention some important Spatial tools in Alteryx.
I hope my Spatial Analytics in Alteryx blog series is helpful to you. Thank you for reading. I hope to see you soon in the next blog!