This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
I have an odd conundrum. I am using the spatial package and am trying to come up with a way to give an overall drive time (or an index of drivetime of some sort) from a series of points. The problem I have is that I don't have a start or end point (you could hypothetically start or end at any of them), but what I'm hoping to do is find maybe the drive time of doing a "lap". Essentially, driving from one of the points, then driving to the next nearest point, hitting them all and returning to the point I started without repeating any of them. Does anyone know if this is possible to set up?
I’ve built out a quick iterative macro (attached) that just starts at the first point, then searches for the next nearest from the remaining points (and so on, and so on…), returning the distance between each point. If you go into the macro you can switch it to drivetimes and your geography, this is just as the crow flies distance for demo, but feel free to change in the drop down of that tool.
Hopefully it’s a macro that you can just plug your data in to. PS- Very keen to stress that this doesn't aim to solve the Traveling Salesman Problem by the way!
Yes, with a dummy data set of stores (which are almost in order anyway) you can iterate through a list, and even batch it if you have multiple 'groups' of lists you want to run at the same time. I've switched it to drive times as well in the UK, so you may need to go into the macros to change that depending on your geography!
Here, a Batch macro contains an iterative macro:
Batch macro = all this is doing is feeding the iterative macro (which has our nearest logic in) a set of lists over and over (e.g. set 1 only, then set 2 only etc.)
Iterative macro = this is where the proper logic happens, we just batch first to make sure there's no records being compared from a different list
See below and attached:
(note that you only need the top macro; the bottom one is just to show you the iterative process that's happening inside the top one)