Reputation: 306
I am using the nearest_edges function in OSMNX. It isn't clear to me what "part" of the edge is used when making this calculation. Is it any part of the edge? Is it the midway point?
For long edges in the network it would make quite a big difference.
Upvotes: 2
Views: 963
Reputation: 6412
It depends on how you parameterized the function. From the nearest_edges
function documentation:
Find the nearest edge to a point or to each of several points.
If X and Y are single coordinate values, this will return the nearest edge to that point. If X and Y are lists of coordinate values, this will return the nearest edge to each point.
If interpolate is None, search for the nearest edge to each point, one at a time, using an r-tree and minimizing the euclidean distances from the point to the possible matches. For accuracy, use a projected graph and points. This method is precise and also fastest if searching for few points relative to the graph’s size.
For a faster method if searching for many points relative to the graph’s size, use the interpolate argument to interpolate points along the edges and index them. If the graph is projected, this uses a k-d tree for euclidean nearest neighbor search, which requires that scipy is installed as an optional dependency. If graph is unprojected, this uses a ball tree for haversine nearest neighbor search, which requires that scikit-learn is installed as an optional dependency.
So if you leave interpolate=None
(ideally using a projected graph and projected points for accuracy), the function will find the nearest edge(s) to your point(s) based on the point's minimum distance to any part of the edge's geometry. This is geometrically precise and is fastest if only searching for a few points in a big graph.
Alternatively, if you pass an interpolate
argument value, the function will interpolate evenly spaced points along the edges, then find the nearest edge(s) to your point(s) based on the point's minimum distance to any interpolated point along the edge's geometry. This is slightly geometrically imprecise (with this imprecision varying with your interpolate
value) but is fastest when searching for many points, particularly in a smaller or mid-sized graph.
Upvotes: 3