3

Look at the picture #1. This is my cost surface raster that has only 2 values. Area restricted for path to cross (red one) and area that is free to go (yellow one). As I need it and as I undestand how it is should work, my least cost path shoul be look like a straight line between two points for most of a time. Practically I have what you can see on picture #2 (performed by r.drain). Cumulative cost gained by using r.cost module showed on picture #3. And to be more clear, what I want to get is showed on picture #4. Basicaly I just need to get minimum distance beetween two points.

Pictures that are showing the problem subject

Is there a way to reach the goal?

  • 1
    This is how costdistance works on a square-celled raster, because there are only eight local directions towards nearest neighbors. To do any better, you would have to write your own algorithm that accounts for more-distant neighbors. – whuber Aug 8 '15 at 16:17
3

I faced the same problem just recently.

And I've found a way of getting a better path. In my case, I was trying to visualise the effect of having the Panama and Suez canals.

My suggestion isn't going to help you find the exact distance, however - but it will trace a more realistic minimum cost path which should be closer in length to the real optimum.

You've got a uniform cost value for the sea, and a high cost value for land. So far, so good.

When I did the least-cost path from Bristol, England to Sydney in Australia, the suggested path hugged the west coast of Africa, before rounding the cape and going in a straight line (line shown in red)

enter image description here

As whuber hinted at, this is caused by lots of local optimums not adding up to a global optimum.

The way I did it was to add peturbation, so that some randomness comes into play.

  • add a random value raster in SAGA GIS ('Random field'), the same size as my cost surface
  • and add this to my cost raster (Grid Sum in SAGA)
  • trace the least cost route on the noisy raster.

In my case I added a value between 0 and 10, as I wasn't bothered about the actual distance, just a better path. I find uniform works better than guassian. I'm using 9999 as the land cost.

Now, with the randomised cost surface, I find the shortest path now crosses diagonally, rather than hugging coastlines. The orange route is the one based on the noisy raster...

enter image description here

In my case I'm using a python script (from the gdal python cookbook) to do the least-cost tracing as a raster, so you mileage may vary depending on how you do the point to point path tracing (I can't get r.drain to work at the moment with QGIS).

  • That sounds very interesting! Also, might work for me aswell. I'm going to try this. Will keep you in touch. Thanks! – AdamJ Aug 8 '15 at 22:15
  • 1
    If you want to remain in the GRASS GIS context, there are a number of options to generate these "noise" maps, too. See grass.osgeo.org/grass70/manuals/keywords.html#random – markusN Aug 17 '15 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.