[GRASS-user] how to measure distances in a constrained space

Hamish hamish_b at yahoo.com
Wed Nov 12 22:14:11 EST 2008


Moritz Lennert wrote:
> >> I would like to measure distances between points
> >> in a constrained space, such as distances between cities,
> >> but only taking into account distances by land, and so
> >> excluding any water bodies. Concretely, this means finding
> >> those cities in a first set of cities which are at least
> >> 150km from the nearest city in the a second set of cities.

Facundo Muñoz wrote:
> > I've implemented exactly the same idea as yours in this script:
> http://www.geeitema.org/doc/guenmap//docs/v.costdist.mat.zip
> >
> > ...with the particularity that it stores the computed distances in the
> > attribute table of the second set of cities, which was needed for my
> > application.
> > You can try it, and see if it works for you.

> I actually now get a correct result with the following
> steps (my original cost map was wrong, that's why my
> results where weird):
> 
> - create a cost map where all land parts are equal to the
> resolution and all water masses are null
> - run r.cost with start_points=set2 (actually no need for
> null_cost) tio create the distance map
> - run v.what.rast vector=set1 raster=distance column=dist_column
>
> And results seem perfectly correct.
> 
> Now just for curiosity, any possible solution in vector
> space ? I thought about v.net.visibility, but it would need
> to be altered to allow a visibility graph from vector1 to
> vector2, instead of only within vector1. Then I guess one
> could use something like v.net.iso or loop through
> v.net.path...


just some extra notes:
- r.cost in GRASS 6.4 should be 60x faster than in older versions
- have a look at the new r.grow.distance in GRASS 7, even faster
- FWIW when I've done this I've made the cost map 1,NULL and multiplied
  the cost distance by map res. knights move is essential.
- See the v.surf.icw script in wiki addons. it is like IDW interpolation
  but replaces euclidean distance with true (cost) distance and goes
  around corners/coastlines.
- Somewhere I had a script for generating distance matrix tables for
  distance between sites taking obstacles into account using r.cost.
  I'd have to hunt for a backup copy.


It would definitely be interesting to hear if you figure something out
with v.net.visibility. you are looking for as-the-bird-flies distance,
not road distance, right?

see ongoing geodesic distance thread on the PROJ4 list for more on the
dangers of measuring long distances on a grid map projection.


Hamish



      



More information about the grass-user mailing list