Alteryx Designer allow you to do geographical analytics very easily. To tell the truth, the GIS tools are required the special knowlege, but you use the Alteryx instead of GIS tools, you can do GIS tasks easily and even automation. Furthermore, you can do the complicated tasks what you do by Python.
In this post, I would like to detemin whether the line objects match.
Compare by IF statement
Basically, you can compare the spatial objects. When the shape is the same, the result of IF statement should be output “true”.
In this case, I create a polyline and another polyline with points drawn in the reverse order and compare them. The following workflow is for making reverse polyline.
Using the Browse tool, you can confirm the detail of the spatial object as follow. You can see that the start point and end point is different.
Of course, they are plotted as the same on the map.
And then let’s compare using IF statement as follows.
IF [SpatialObj]=[SpatialObj_Reverse] THEN "True" ELSE "False" ENDIF
It is very simple IF statement. As a result, it shows “True”.
The start point and end point is not the same, but the IF statement shows “true”. In other words, the Designer considers them the same objects. But in other point of view, it is not correct. For example when you use the route between point A and point B, if the start point is not the same, the navigation is not the same. When you want to use the point order in line object, the order is very important. So, in this case, you can not use this comparing method. You can use ST_MD5 function.
Compare using ST_MD5 function
ST_MD5 function is to get MD5 hash value of the Spatial Objects. For comparing the two spatial object is strictly the same or not, you can use this function.
Let’s do a specific sample. In this case I compare two polylines which I compared above by getting MD5 hash value. The MD5 hash values are as follows by ST_MD5 function.
Surely, these MD5 hash values are different.
Note that MD5 hashes have problems with collision resistance and are no longer used much these days, so it is possible that the exact same hash could be generated. But actuallly I think it can be used quite well.
Compare as text
To be the honest, Spatial Object in Alteryx is just GeoJSON format. So, you can change them to the text type such as the V_String by the Select tool.
After changing to the text type from Spatial object, you can just compare them as string.
How about the Polygons?
I write about Polylines so far, how bout polygons?
To get straight to the conclusion, you can just compare the polygons using IF statement directly.
I tried to make the polygon which have different start point, but Alteryx Designer always made the strictly same polygon. So, of course they have the same MF5 hash and the same text. It seems like how to decide the start point and order is decided. Certainly, the order of the points is decided as the specification, outer polygon is clockwise and inner polygon is counterclockwise. This is the specification of ESRI Shapefile.
Conclusion
- Polylines(lines) have orientation at their interior points. So it looks like the same, the orientation may be different. For compareing, IF statement is used for comparing the appearance shape. However, if you want to compare the appearancewith the orientation of the interior points, you have to use ST_MD5 function or comparing as text.
- Regarding the Polygon, it was decided how to create in the specification, so if the start point is different, the Designer creates the same polygon. As a result, you can compare using IF statement.
- Regarding the Multi-Point and the Multi-Polygon, you can compare by IF statement, but you have to do the same way of the Polyline(line) to compare the Multi-Polyline.
Sample Workflow Download
Contents of the next blog
The next post will be about the Join tool.
コメント