Currently, I am conducting spatial analysis in R over a taxi data set. The data set gives lat-long coordinate pairs to denote where someone was picked up and dropped off, and I am also working with a road network with clearly defined street intersection nodes. I am looking for a way to find the nearest street intersection when given a certain pair of coordinates in the reference system:
nearestNeighborID <- someFunction(myNetwork, xCoordinate, yCoordinate)
I believe there may be such a function in R's sp or igraph packages, but I haven't been able to find anything yet: only a gdistance function which computes the distance between two given points. Does anybody know of such a function in R where you may find the nearest vertex/feature in a network when given an xy point in space?
Also, here is an example of my network and some pickup/dropoff locations. I apologize that it is a bit messy, but the fairly organized square is the street network, and the strewn-across points are the locations that I wish to approximate to the nearest street intersection (an example is the bottom right point with the blurry ID number): https://i.stack.imgur.com/qeKEf.jpg.