I would like to get Start node id and End node id of a certain way in openstreetmap data. I have the following code in Jupyter notebook.
import pandas as pd
import geopandas as gpd
region = “switzerland”
handler = StreetsHandler()
osm_file = f"{region}-latest.osm.pbf"
w_id 4087346
geo LINESTRING (8.857527 46.2049215, 8.8575004 46…
cycleway NaN
highway tertiary
lane_markings NaN
…
overtaking:hgv:backward NaN
hgv:lanes:backward NaN
bridge:support NaN
temporary:highway NaN
turn:lanes:both_ways NaN
Name: 89, Length: 1054, dtype: object
How could I get the Start node ID and End node ID of the way with w_id=4087346?
Thank you very much for your answer. It is what I was looking for. Now, if I have a certain number of ways for example, two here, is there a possibility to loop through text file with the way IDs instead of typing each way?
[out:json];
way(4087346);
out geom;
way(4248968);
out geom;
If you know the way ID you can also use directly the OpenStreetMap API to get the details of the way.
For a human way to review things I sometimes open the way using the web browser, for example w4087346, it has the list of nodes and also indicates if it is part of a relation.
You unfortunately have left out two very important pieces of information in your post: the name of the library you are using, which is pyosmium, and the implementation of your handler function StreetsHandler. The way() callback in latter gives you the node ids. You need to do something along the lines of: