[R-sig-Geo] minimum distance between polygons' edges

Adrian Baddeley adrian at maths.uwa.edu.au
Fri Mar 6 05:04:12 CET 2009


arion TAFANI wrote:

>
> > we want to calculate the minimun distance between polygons' edges , do 
> > you know any package or function which can help us ? we try to work 
> > with vectors rather than raster but we lack some tools. we only found 
> > how to calculate distances between centroids but nothing between edges.
>
>   
This is implemented in the package 'spatstat'.

For objects of class "psp" (representing collections of line segments) 
the function pairdist.psp computes the distance between each pair of 
line segments. There is also a function crossdist.psp for comparing two 
sets of line segments.

To convert your data from sp classes (like SpatialPolygons or 
SpatialLines) to the class "psp", see the vignette provided in the 
spatstat package.

Note that the shortest distance between two line segments is not the 
same as the minimum distance between their endpoints. So the other 
solutions which have been suggested will not give the correct answer.

Adrian Baddeley



More information about the R-sig-Geo mailing list