[R-sig-Geo] Coordinates of the closest point
Juta Kawalerowicz
juta.kawalerowicz at nuffield.ox.ac.uk
Thu Jun 25 16:40:55 CEST 2015
Many thanks for your kind suggestions, they provided a sufficient solution
to the problem.
Juta
On Wed, Jun 24, 2015 at 5:07 AM, Robert J. Hijmans <r.hijmans at gmail.com>
wrote:
> And for longitude/latitude data you can use geosphere::dist2Line
> Robert
>
> On Tue, Jun 23, 2015 at 8:13 PM, GeoTux Tuxman
> <geotux_tuxman at linuxmail.org> wrote:
> > Hi Juta, you can do this (only with planar coordinates):
> >
> > require("maptools")
> > coordsLine = cbind(c(1,2,3),c(3,2,2))
> > coordsPoint = c(1.2,1.5)
> > nearestPointOnLine(coordsLine, coordsPoint)
> >
> > If you have a SpatialLinesDataFrame get the coordinates this way:
> > coordsLine = coordinates(line)
> >
> > Note that coordsLine should contain coordinates of a single line.
> >
> > See [1] for details.
> >
> > Regards,
> >
> > Germán Carrillo
> > ---------
> > [1]
> >
> http://geotux.tuxfamily.org/index.php/en/component/k2/item/296-snapping-points-to-lines-in-r
> > --
> > -----------
> > \__
> > (:>__)(
> > /
> > Soluciones Geoinformáticas Libres
> > http://geotux.tuxfamily.org
> > http://twitter.com/GeoTux2
> >
> >
> > Sent: Tuesday, June 23, 2015 at 5:55 PM
> > From: "Juta Kawalerowicz" <juta.kawalerowicz at nuffield.ox.ac.uk>
> > To: r-sig-geo <r-sig-geo at r-project.org>
> > Subject: [R-sig-Geo] Coordinates of the closest point
> > 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
> >
> > _______________________________________________
> > 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