[GRASS-dev] About v.distance, v.what.vect (wrt "count points within...").

Markus Metz markus.metz.giswork at googlemail.com
Tue Aug 10 05:19:51 EDT 2010


Moritz Lennert wrote:
> Nikos Alexandris wrote:
>>
>> "v.distance" is slow (for the impatient user) with very large vectors
>> (from my
>> memory I estimate that it took ~20h for ~600.000 features). Trying to get
>> the
>> "dmax=" first in order to tell "v.distance" to look for features within a
>> certain radius, might _not_ be very efficient as well. It takes time to
>> get
>> results from "v.distance -pa" and, depending on the vector(s), the
>> addition of
>> the _real_ v.distance can be a deal-breaker.
>
> Just an innocent question (partly directed to Markus M): could this be
> linked to the spatial index ? And is v.distance faster with spatial index on
> file in grass7 ?
>

No consistent speed difference between grass 6.x and grass 7.
Sometimes grass 6 is faster, sometimes grass 7, but nothing dramatic.
The time-consuming parts are distance calculations and tests whether a
point is inside an area or inside an isle of an area. These
calculations should be done only when necessary. I have added some
tests using bounding boxes to my local copy to avoid
distance-from-point-to-line calculations; in combination with dmax and
without -a there is a real speed gain for point to area distances, but
I need to do more testing to make sure results stay identical.

It might save some time to get distances from points to centroids
first with -p (I don't think -a is necessary) because getting
distances to centroids is much faster than getting distances to areas.
Grab the maximum distance and use that as dmax with to_type=area. This
should be safe because the real maximum distance to areas should be
smaller than the maximum distance to area centroids.

Markus M


More information about the grass-dev mailing list