Skip to content

distance to polygon (and line_

1 message · Rolf Turner

#
On 1/11/2010, at 7:38 AM, Peter Larson wrote:

            
In R all things are possible.

You may have problems with units; the units in which your points are expressed
must be the same as those in which the lines and polygons are expressed.

If you can express everything in terms of two dimensional Euclidean units,
then the facilities of spatstat will allow you to do what you want.  Currently
spatstat does not handle great circle distances.

If you express your collection of polygons as a single owin object, say "xxx", then
distfun(xxx)(x,y) will give the distances from to xxx.  These will be the
minima of the distances from the points to the individual polygons.

Likewise if you express your collection of lines as a psp object, say "lll",
then distfun(lll)(x,y) will the distance from each point to the nearest line.

In the foregoing "x" represents the vector of x-coordinates of your points,
and y the vector of y-coordinates.

See

	vignette("shapefiles")

for instructions on how to turn shapefile data into spatstat style objects.

	cheers,

		Rolf