<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>Hi Juta, you can do this (only with planar coordinates):</div>

<div> </div>

<div>require("maptools")</div>

<div>coordsLine = cbind(c(1,2,3),c(3,2,2))<br/>
coordsPoint = c(1.2,1.5)<br/>
nearestPointOnLine(coordsLine, coordsPoint)</div>

<div> </div>

<div>If you have a SpatialLinesDataFrame get the coordinates this way:</div>

<div>coordsLine = coordinates(line)</div>

<div> </div>

<div>Note that coordsLine should contain coordinates of a single line.</div>

<div> </div>

<div>See [1] for details.</div>

<div> </div>

<div>Regards,</div>

<div> </div>

<div>Germán Carrillo</div>

<div>---------</div>

<div>[1] <a href="http://geotux.tuxfamily.org/index.php/en/component/k2/item/296-snapping-points-to-lines-in-r" target="_blank">http://geotux.tuxfamily.org/index.php/en/component/k2/item/296-snapping-points-to-lines-in-r</a></div>

<div class="signature">--<br/>
-----------<br/>
   \__<br/>
(:>__)(<br/>
   /<br/>
Soluciones Geoinformáticas Libres<br/>
<a href="http://geotux.tuxfamily.org" target="_blank">http://geotux.tuxfamily.org</a><br/>
<a href="http://twitter.com/GeoTux2" target="_blank">http://twitter.com/GeoTux2</a></div>

<div> 
<div> 
<div style="margin: 10.0px 5.0px 5.0px 10.0px;padding: 10.0px 0 10.0px 10.0px;border-left: 2.0px solid rgb(195,217,229);">
<div style="margin: 0 0 10.0px 0;"><b>Sent:</b> Tuesday, June 23, 2015 at 5:55 PM<br/>
<b>From:</b> "Juta Kawalerowicz" <juta.kawalerowicz@nuffield.ox.ac.uk><br/>
<b>To:</b> r-sig-geo <r-sig-geo@r-project.org><br/>
<b>Subject:</b> [R-sig-Geo] Coordinates of the closest point</div>

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