Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
SOLVED

Calculating distances Using a Road Network Shapefile

tremblax
5 - Atom

Hello Alteryx Community,

 

I've tried to avoid posting on the community pages, as so often the questions I want to ask have been answered dozens of times, but I have yet to see a resolution to my query.

 

I do not have a spatial license (thank you IT dept haha), so I went rogue and downloaded the road network file for my local province here in Canada.  I can easily build points along the road network 5 or 10km apart. That isn't too much of a problem.

But is it possible to do the following?

 

Once I have a set of points along this road network, could I go about building a new spatialobj field for each point, which represents all of the road segments accessible within 25km of that point? . So to make it a bit clearer, I'm trying to figure out how far one of our installers could make it in a 25km path in any direction from a set of given start points.

 

1) does my question make sense?

2) is it possible?

 

Thank you!

 

 

6 REPLIES 6
Hannah_Lissaman
11 - Bolide

Hi @tremblax 

 

Could you explain a little more about the part of this that you are able to do? I don't think I fully understand what you have built from the shapefile, and therefore what your starting point for this query is.

 

Are you able to post a data and workflow sample? Alternatively, could you share a little more detail about exactly what you mean by a road segment, whether the distances you mention are straight line or follow the road shape, and what you want your final output to look like?

 

The final step to this will almost certainly involve creating a batch macro which can work out all of the places you can get to from a point in 25km. However, to give you a full answer, I need to understand what your current state looks like.

tremblax
5 - Atom

Yes- I was a little vague on details, my apologies.

 

I am using the road network file provided by Statistics Canada. It's a full map of all roads in the country. Each row of data represents one road segment, and they vary in length considerably, as each segment starts and ends at an intersection. Therefore, rural road segments could be 5-10km in length, and urban roads, or collectors/exit ramps could be a only a few meters. Our company services rural customers, so straight line distances to customer homes are often irrelevant as road networks are pretty sparse, and often times travel to homes 10km apart as the crow flies results in 25km of driving (or ferries, or ATV trails etc)

 

I was planning on plotting our installer locations onto the road map (I will build the points, but let's imagine I just have one installer for now).  I want to know all of the areas they can get to if they drive 25km across road network in any direction. That would represent a "service area" for our installer

 

The output file would be a shapefile of all parts of the road network they could reach. I don't care about any of the details provided by Stats Can. One spatialobj field with the roads within 25km would work. I don't even care about direction, just one blob of all of the potential roads they could reach.

 

Does that make sense?

 

Thank you for your help.

Hannah_Lissaman
11 - Bolide

Hi @tremblax 

 

Thank you for the extra info. I have been able to build a demo for you which will hopefully meet your requirements. 

 

To combine the road segments, I have created an iterative macro. In each iteration, it uses Spatial Match to find road segments which are adjacent to the ones already included in the area. It then combines them with the existing spatial object and checks the overall length to see if it is over 25km. If not, it adds the combined spatial object back to the iterative input and repeats the process. This method creates a list of different 'routes' which are around 25km in length from the given starting point. 

 

If you would like to combine the routes into a single spatial object, use a Summarize tool after the macro.

 

Take a look at the attached workbook with macro - you will need to add the shapefile as input (i didn't include in the package due to size). I have added comments for the key steps. Let me know if you have any questions.

 

Note: If the 25km mark falls within the road segment, this method will include the whole road segment, so the outer edges of the spatial object may be slightly over 25km away. However, the segments are mostly very small, so this is hopefully not a major issue. The macro will output the length of each 'route' so you can see how much over 25km they are.

tremblax
5 - Atom

Thank you so much. I will look into this right now and get back to you.  Thank you for being so helpful!

 

 

EDIT: Need to do an alteryx update to open the package. Will need to engage IT, so it might be a bit before I can look into it.

tremblax
5 - Atom

Very cool solution. I'm willing to accept a pretty wide tolerance, but there are about 2000 segments >15km and about 100 of them > 100km. Perhaps I can split the culprits before running your solution. Shouldn't be an issue.

 

Thank you again, so much. This is precisely what I was looking for. 

 

 

 

-Tim

 

 

Hannah_Lissaman
11 - Bolide

That sounds like a sensible approach - a bit of data prep should solve the issue.

 

Also, for opening the package you can right click on the file in its folder and unzip it. If you then open the macro, then the main workflow, it should open in your version.

Labels