[R-sig-Geo] Coordinates of the closest point

Michael Sumner mdsumner at gmail.com
Wed Jun 24 02:06:22 CEST 2015


Use spDistsN1 to calculate the distances from the line coordinates to your
point and find the shortest distance, then use that index back into the
coordinates.

You can get all coordinates from a line with something like this, but it
depends on your object - is it a simple 1-line object etc so you might need
to subset it or delve.

coordinates(as(x, "SpatialPoints"))



On Wed, 24 Jun 2015 at 08:55 Juta Kawalerowicz <
juta.kawalerowicz at nuffield.ox.ac.uk> wrote:

> Hi, I know how to get the closest distance from a spatial point to a
> polyline, but I was wondering if there is any easy way to also get
> coordinates of the closest point on the polyline?
>
> A longer way to go around this would be to build a buffer around spatial
> point with radius equal to whatever is returned by gDistance() and then
> look for intersections but there must be an easier way?
>
> Cheers,
> Juta
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list