[R-sig-Geo] Distances between points bounded by a polygon

Roger Bivand Roger.Bivand at nhh.no
Wed Mar 21 10:57:52 CET 2007


On Tue, 20 Mar 2007, Andrew Niccolai wrote:

> Greetings spatial R users,
> 
> I have a question that is most likely straightforward but I am stuck on this
> one!
> 
> I have a set of points that can be of the class "SpatialPoints" or of the
> class "ppp" and they reside within a polygon of the class either
> "SpatialPolygons" or "owin".  I also have a set of pixels of class
> "SpatialGridDataFrame" associated with the polygon.  I would like to
> calculate the distance between the points for every pixel in the
> "SpatialGridDataFrame" that is bounded by the polygon/owin object.
> Essentially the distmap function in spatstats package is what I am striving
> for but it seems to produce a distance map that is bounded by a rectangular
> "bounding box" of the extreme points.  I have tried to set the as.mask
> function but it gives me an error:  
> "
> >V <- distmap(test7, as.mask(test8))
> >Error in diff(w$yrange)/eps : non-numeric argument to binary operator
> "
> 
> Any ideas or code that would enable me to "spread" that distance map
> function across the entire polygon/owin or SpatialGridDF would be
> tremendously appreciated.

In cases like these, it would be enormously helpful to have access to a 
toy data set, for example a set.seed() runtime generated set of points, 
convex hull generated polygon and grid (via overlay), and your code so far 
illustrating the problem. Otherwise it is very easy to answer what appears 
to be the question but isn't. The spatstat package is very rich, and I'd 
be surprised if there isn't a way of doing this directly with its 
functionality.

Roger


> 
> Again, I would like to thank the the people that take the time to ask and
> those that answer these types of questions on the list serve!!
> 
> Cheers
> Andrew Niccolai
> Doctoral Candidate
> Yale University
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list