-1

Here is a docs:

osmnx.distance.nearest_edges(G, X, Y, interpolate=None, return_dist=False)

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.

Parameters: G (networkx.MultiDiGraph) – graph in which to find nearest edges

X (float or list) – points’ x (longitude) coordinates, in same CRS/units as graph and containing no nulls

Y (float or list) – points’ y (latitude) coordinates, in same CRS/units as graph and containing no nulls

interpolate (float) – spacing distance between interpolated points, in same units as graph. smaller values generate more points.

return_dist (bool) – optionally also return distance between points and nearest edges

Returns:

ne or (ne, dist) – nearest edges as (u, v, key) or optionally a tuple where dist contains distances between the points and their nearest edges

Return type:
tuple or list

Here is a question

But what is crs? why cant I use a normal longitude and latitude here? points are 6467474 something like this(dtype:float64). I am new to GIS. u v key

  • Please provide a complete, minimal, reproducible code snippet so we can diagnose and troubleshoot. It's impossible to guess what you're doing here. – gboeing Oct 23 '22 at 17:01

1 Answers1

0

What is CRS/units in osmnx python?

Are you asking what these terms mean? Or what their default values are? If it is the former, you can refer to any introductory GIS textbook. If it is the latter, as the OSMnx documentation states, the default CRS is EPSG:4326. Regarding distance units, it depends on what you did in your code. You did not provide a complete, minimal, reproducible example. If you projected your graph, then distances are measured in whatever units your projection is in. If you did not, then distances are measured in meters by default.

why cant I use a normal longitude and latitude here?

As the documentation states, you can pass in latitude and longitude to find the nearest edge(s) to point(s). I would strongly encourage you to work through the OSMnx usage examples to learn how the package works and practice some demonstration code (including find nearest edges to lat-lng points).

points are 6467474 something like this(dtype:float64). I am new to GIS. u v key

I don't know what you mean. Again, you need to provide a complete, minimal, reproducible code snippet so we can diagnose and troubleshoot. If you do, I can edit this answer if your code snippet provides enough info for me to give further information.

gboeing
  • 5,691
  • 2
  • 15
  • 41