Find the co-ordinates on a line at the closest point to another point in R
<p>Working in R I have 2 objects, a SpatialLinesDataFrame (representing a road network) and a SpatialPointsDataFrame (representing object locations). I need to output the co-ordinates on the road of the point closest to each of the object locations.</p>

<p>All I can find from searches are methods for doing this in other languages (e.g. Python - <a href="https://stackoverflow.com/questions/28931007/how-to-find-the-closest-point-on-a-line-segment-to-an-arbitrary-point">How to find the closest point on a line segment to an arbitrary point?</a>) or for finding the minimum distance between the points and line (e.g. using <code>geosphere::dist2Line()</code> or <code>rgeos::gDistance()</code>). I am interested simply in returning the co-ordinates of the nearest point on the line.</p>

<p>EDIT:
Here is a small subset of my road network:</p>

<pre><code>new("SpatialLinesDataFrame"
    , data = structure(list(ID = c(0, 0, 0, 0, 0, 0, 0),
                            ET_ID = c("4", "4", "4", "4", "4", "4", "4"),
                            length = c(0.280848, 0.812133, 0.0402004, 0.209611, 0.0433089, 0.501865, 0.363501)),
                       .Names = c("ID", "ET_ID", "length"),
                       row.names = c(980L, 982L, 983L, 984L, 987L, 988L, 989L),
                       class = "data.frame")
, lines = list(&lt;S4 object of class structure("Lines", package = "sp")&gt;, 
               &lt;S4 object of class structure("Lines", package = "sp")&gt;, 
               &lt;S4 object of class structure("Lines", package = "sp")&gt;, 
               &lt;S4 object of class structure("Lines", package = "sp")&gt;, 
               &lt;S4 object of class structure("Lines", package = "sp")&gt;, 
               &lt;S4 object of class structure("Lines", package = "sp")&gt;, 
               &lt;S4 object of class structure("Lines", package = "sp")&gt;)
, bbox = structure(c(433266.568837884, 547825.73420664, 437050.511867258, 548168.921069476),
                   .Dim = c(2L, 2L),
                   .Dimnames = list(c("x", "y"), c("min", "max")))
, proj4string = new("CRS", projargs = "+proj=utm +zone=37 +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
)
</code></pre>

<p>and of my object locations:</p>

<pre><code>new("SpatialPointsDataFrame"
    , data = structure(list(x = c(38.4129, 38.41697, 38.41501), y = c(4.95659, 4.95809, 4.96122)),
                       .Names = c("x", "y"), row.names = c(105L, 166L, 185L), class = "data.frame")
    , coords.nrs = numeric(0)
    , coords = structure(c(434912.0166297, 435363.392542353, 435146.398500838, 547894.637850701, 548060.055746692, 548406.25007762),
                         .Dim = c(3L, 2L), .Dimnames = list(c("105", "166", "185"), c("x", "y")))
    , bbox = structure(c(434912.0166297, 547894.637850701, 435363.392542353, 548406.25007762),
                       .Dim = c(2L, 2L), .Dimnames = list(c("x", "y"), c("min", "max")))
    , proj4string = new("CRS", projargs = "+proj=utm +zone=37 +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
)
</code></pre>

<p>Thanks in advance!</p>