I'm struggling with a rather odd problem with the python package
I have lots of GPS points in a pandas dataframe that were originally in EPSG 4326, but I've already projected them onto EPSG 32633 (UTM zone 33N). My aim is it to find the nearest OSM edge. For the sake of an example, let's look at the point
(388860.7103015079, 5828739.389188443). One can look at this point here (might not work - maybe you have to enter the point manually).
Now I am using
OSMNx and its
get_nearest_edges(), respectively) to find the nearest OSM edge. As the graph input, I use a rather small bounding box including the coordinates, as retrieved by, e.g.,
G = osmnx.graph.graph_from_bbox(52.607584, 52.573916, 13.357185999999, 13.424399999999999, network_type='drive', simplify = False),
but I guess it should also work, if you'd get the whole Berlin map.
G = osmnx.graph_from_place("Berlin, Germany", network_type="drive", simplify = False.
Normally, I have a whole pandas data frame of points and I run
osmnx.get_nearest_edges(G, df["lon_proj"], df["lat_proj"], method="kdtree", dist=0.0001)
For example's sake, let's run instead
Using the latter command, I end up with a tuple of OSM nodes specifying the edge I should be looking for:
(1873509499, 732609150, 0). Now there are two problems. First, the OSM edge depends on the graph I am giving to that function (but note that both graphs
G stated above contain the example point). Second, the nodes attained by this output are not really close to the original point (compare here).
Why won't the function give me the actual nearest edge, even though there are nodes much more close-by than the ones I am attaining? In the picture below you can see the node that is my desired output (orange) and the node attained by
Edit: I figured that apparently
osmnx.get_nearest_edge() takes a tuple of (lat, lon) coordinates (so latitude goes first), while
osmnx.get_nearest_edges() does it the other way round. Now using the former works, but using the latter still gives super random results. Perhaps you guys have an idea about this.