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"
start data file processing
handler.apply_file(osm_file, locations=True, idx=‘flex_mem’)
show stats
print(f"num_relations: {handler.num_relations}“)
print(f"num_ways: {handler.num_ways}”)
print(f"num_nodes: {handler.num_nodes}“)
print(f"num_roads: {handler.num_roads}”)
create dataframes
street_relations_df = pd.DataFrame(handler.street_relations)
street_relation_members_df = pd.DataFrame(handler.street_relation_members)
street_ways_df = pd.DataFrame(handler.street_ways)
street_roads_df = pd.DataFrame(handler.street_roads)
print(street_ways_df.iloc[89])
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?
11 posts - 6 participants
Ce sujet de discussion accompagne la publication sur https://community.openstreetmap.org/t/how-to-get-start-and-end-node-id-of-a-certain-way-with-way-id/97926