[R-sig-Geo] Closest point in R

Adrian.Baddeley at csiro.au Adrian.Baddeley at csiro.au
Fri Jun 22 11:50:58 CEST 2012


In spatstat, for a polygon window P and a point pattern X you can do 

    L <- as.psp(P)
    Z <- project2segment(X, L)
    Y <- Z$Xproj

Then Y[i] is the nearest point to X[i] on the boundary of P.
Other components of Z give you the distance from X[i] to Y[i], etc.

Adrian Baddeley


On 22/06/12 06:15, Ted Rosenbaum wrote:
> Hi,
> I am looking for a way (preferably in spatstat) to obtain the point in a
> polygon (window in my spatstat context) that is closest to a given point
> outside of it (similar to closestpoint in postgis).  Approximations
> (something that is approximately the closest point) are fine in my context
> Thanks,
> Ted
>
> ---------------------------------------------
> Ted Rosenbaum
> Graduate Student
> Department of Economics
> Yale University



More information about the R-sig-Geo mailing list