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

Moritz Lennert mlennert at club.worldonline.be
Thu Nov 13 03:44:44 EST 2008


On 13/11/08 04:14, Hamish wrote:
> 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

Am using grass7, can confirm that it is really fast.

> - have a look at the new r.grow.distance in GRASS 7, even faster

r.grow.distance creates a distance map from each point, but there is no 
way of telling it anything about null cells or barriers. Even when 
setting a mask, r.grow.distance fills in the whole region, which seems 
like a bug to me.

> - FWIW when I've done this I've made the cost map 1,NULL and multiplied
>   the cost distance by map res.

What's the difference to directly using a cost map res,NULL ?

>  knights move is essential.

I guess that's an issue of precision, or ? For me "normal" moves 
correctly identifies the cities I'm looking for.

> - 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.

Interesting, but:
"Input data points [...] but should be kept within a few dozen as the 
module becomes very computationally expensive"

IISC, Facundo's module is based on that, or ?

So also not really an option with >1000 points.

> - 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.

Well the above works, i.e. just setting obstacles to NULL in the cost 
map. Obviously this only works if obstacles represent total barriers, 
not just increased friction.

> 
> 
> 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?

Road distance would be even better, but the v.net.* modules 
unfortunately don't scale at all...

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

I'll have a look, thanks !

Moritz


More information about the grass-user mailing list