Hello Alteryx Users,
I've a trade area polygon that I'm creating for every customer based on a given drive time. Once I've that, I need to find the farthest point from this customer location point to the polygon in miles/km. So the Trade Area polygon is drive time based from customer location, but then the final output I want is the farthest distance in miles from this customer location to the polygon edge. It does not matter if the longest distance is South, North etc. Just need one point. Slight approximation is OK as well.
I can do the first part w/o any issues (customer to lat/long point to Trade Area). I'm not sure which tool to use for 2nd part.
When I look inside the TA Polygon, I do see few things I might be able to use, but I'm not sure how to access these.
e.g. (actual values hidden)
Solved! Go to Solution.
Right or wrong, this is how I would approach the challenge. First, I would SPLIT the polygon to POINTS. Then I would append these points to each customer record. This is going to mean that a single record will get split to MANY records. Then I would calculate the distance to every point on the polygon. Now I can sort and find the furthest distance.
I hope that this picture and description help.
Cheers,
Mark
MarqueeCrew,
Thank you for quick response. Your approach is doable but it is going to explode my data set as I've large polygons (example below is 1K points for a smallish polygon) and 1/2 MM customers. But frankly, I had not seen that transformation. So at least now I've a way.
My other thought was the MAX LAT/LONG that is available within the polygon. I see it when I click on it but don't know how I can get to it in the flow. If I can do that, I'll get the farthest 2 points, Is this not what it seems to be?
Type: Polygon
I would approach this challenge in the same way as @MarqueeCrew too.
I believe the information with which you are trying to access isn't necessarily the 'MAX' but more the first and last points of the polygon; that is my understanding anyway. A quick way to test this would be to use the above method on just a single polygon and then access the information manually using your method and see if it is pulling the same point.
If it is then we can look at how to access it, if it isn't then it's not something we should look to do!
Ben
I have now just found how we can pull the data you have highlighted, again this might neccesarily be correct so be sure to check it against @MarqueeCrew's method.
You can use the formula tool and the functions spatiST_MaxX(object) and spatiST_MaxY(object) to return the maximum latitude and longitude of the polygon.
The formula tool also has the same functions for Min too.
Ben
Thank you, BenMoss.
I tried MarqueeCrew's method and it works. But scaling is impossible. That will mean writing a macro to iterate over some grouping factor or run it in batches. So it will be worth checking what you suggest and match it with few customers from the other method.
I'll try this and report back either way.
Thank you.
Thank you both for your replies.
I tried the formula method. I'm not sure about it as the Max/Min X Y as I did not get very predictable results. Plus validating was a pain.
On a good note, I was able to brute force my way through MarqueeCrew's solution. It takes time to run the entire set as the data explodes for large trade areas, but Alteryx came through. This is not an everyday process, so time is not as critical. I'll mark that as an acceptable solution.
Thank you.
This helped me solve Weekly Challenge 311, thank you!!