How to generate multiple paths between fixed source and destination points?

3694
3
Jump to solution
11-17-2014 03:46 PM
SaraGhandehari
New Contributor

Hello everybody,

Does anybody know how I can generate multiple paths (not just least cost one) between two points? I want to have several alternatives of paths connecting two point in my map.

I have an idea of writing a code with "for" loop and use "costPath" tool in each iteration and find LCP; then exclude the resulting LCP from the model prior to the next iteration and find a new LCP.

I have no idea how to perform it!! Is there a way to do this algorithm in ArcMap by python scripting?

I hope I am clear enough to explain the issue.

Thank you,

Sara

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

I have done a similar analysis trying to obtain multiple routes between two points. What I did was to include in the next step the previous route as exclusion (NoData in the cost raster for a small buffer around the vectorized path). Make sure that for a small area around the start and end point you leave the cost values, since otherwise you will not get any result.

View solution in original post

0 Kudos
3 Replies
XanderBakker
Esri Esteemed Contributor

I have done a similar analysis trying to obtain multiple routes between two points. What I did was to include in the next step the previous route as exclusion (NoData in the cost raster for a small buffer around the vectorized path). Make sure that for a small area around the start and end point you leave the cost values, since otherwise you will not get any result.

0 Kudos
SaraGhandehari
New Contributor

Thank you very much Xander for your help,

Do you know how I can relax the assumption of NoData in areas around start and destination?

I used the tool "Expand raster" to create a buffer around my LCP raster and set all cells in the buffer to NoData. I dont know to retain the values for area around start and destination.

Sara

0 Kudos
XanderBakker
Esri Esteemed Contributor

I used a procedure which was vector based and consisted of the following steps:

  • Create a buffer of the vectorized route (with a small distance, but a least 1 pixel)
  • Create a buffer of the start and end points of the route (with a slightly larger buffer than the buffer around the route)
  • Erease the buffer of the start and end points from the buffer of the route
  • Use the remaining polygon to set NoData cells in the cost raster

Since your source and end points are raster, you can use the expand to create a raster holding the source and destination pixels and some pixels arround them. You also need the buffer of the route (or another expand raster on the raster that holds the pixels of the route) to combine them into a new cost raster.

What you want to do is create some map algebra that will do the following:

  • When the expand of the source and destination cells is NoData,
    • then verify if the route buffer is NoData, in that case assign the original cost raster values,
    • else assign nodata.
  • in case the expand source and destination cells have a value, you should assign the origina cost raster.

Suppose you have the following rasters:

  • xpnd_src_dest (raster result of appyling the expand to the source and destination cells)
  • xpnd_route (raster result of applying the expand to the route cells)
  • cost_ras (your original cost raster)
  • nd_ras (a raster containing only NoData cells, I have had many problems with the SetNull function, therefore I use an alternative)

The Map Algebra in the Raster Calculator would look something like:

Con(IsNull("xpnd_src_dest"), Con(IsNull("xpnd_route"), "cost_ras", "nd_ras"), "cost_ras")

This will yield a cost raster that you can use in the next run.

Kind regards, Xander

0 Kudos