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

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Tue Aug 10 09:30:49 EDT 2010


Markus M:

> >> If a point is inside an area (the polygon composed of the area's 
> >> boundaries), the distance is 0 (zero):

Nikos A:

> > This sentence makes me think that it is a priori known (based on
> > something else - related to topology?) when a point is inside an area.
> > Why all the need to measure distances then in order to count how many
> > points are inside?

Moritz L:

> As you can see in the code referenced by Markus, there is a
> Vect_point_in_area(), so yes, it is possible to more directly check if
> points are in areas. It all depends on which modules were written using
> this function. At this stage all point-in-polygon attempts in GRASS are
> scripts using workarounds...
 
> >> A centroid is always inside the area it belongs to, therefore the
> >> distance of a point outside an area to the area's centroid is always
> >> larger than the distance of that point to the area's boundaries.
> > 
> > What happens when the centroid (gravity center) falls outside of the
> > boundaries?
> 
> In GRASS, by definition a centroid is within the boundaries, and so does
> not necessarily represent center of gravity.

Right!

> >>> Point to boundary? Specifically, point to all-lines that compose a
> >>> boundary? Many distances? And then, keep the maximum?

> >> If a point is outside an area, v.distance determines the shortest
> >> distance to the area's boundaries (point to all-lines that compose a
> >> boundary), IOW, keep the minimum not the maximum because v.distance
> >> searches for the nearest feature.

> > All right. But, (repeating the same question): why is distance measuring
> > required at all? To compare it with what?

> Well, v.distance was not meant as a point-in-polygon measurement tool,
> but as a distance measurement tool. v.what.vect just "abuses" it as
> such, using dmax=0.0. But currently, there is not dedicated
> point-in-polygon counting module...

That is rather good news (I think). There is room for a unique count points 
within areas tool then.

> > Why are (supposedly) other tools faster in counting points within
> > polygons?

> see above...

> So, maybe, if you have a dedicated programmer at hand, you could imagine
> a module with point-in-polygon algorithm, maybe giving the option of
> counting the points, aggregating some attribute values of the points,
> etc, using the Vect_point_in_area() function...
> 
> Should just be a matter of:
> 
> - opening a polygon and a point layer
> - for each polygon
> 	- loop through all points and if Vect_point_in_area() is true,
> aggregate the values of those that fall into the polygon
> - put results into table of polygon map, new table or stdout
> 
> I imagine that here the use of bounding boxes and the spatial index
> might here, but that's Markus' specialty ;-)

Thanks a zillion ;-) 
Nikos

(bcc-ing a potential dedicated programmer)


More information about the grass-dev mailing list