So to briefly describe what I'm doing - I have a CSV of ~65,000 driving routes with start postcodes and end postcodes and I want to get for each route a list of lat/lon coordinates along the route.
So my first step was to go to OSRM project API and take out the nodes along a route using the following code
route = requests.get(f'http://router.project-osrm.org/route/v1/driving/{StartLL};{EndLL}?alternatives=false&annotations=nodes')
routejson = route.json()
route_nodes = routejson['routes'][0]['legs'][0]['annotation']['nodes']
Next I now want to take those nodes and convert them to lat/lon coordinates but I've found an API to do this from openstreetmaps, but it will take forever looping through 66,000 records each with a couple of hundred/thousand nodes.
for node in route_nodes:
response_xml = requests.get(f'https://api.openstreetmap.org/api/0.6/node/{node}')
response_xml_as_string = response_xml.content
responseXml = ET.fromstring(response_xml_as_string)
for child in responseXml.iter('node'):
RouteNodeLL.append((float(child.attrib['lat']), float(child.attrib['lon'])))
I know there's a .osm.pbf file I can download but I have no idea how to extract the nodes out of it.
Is there a way I could do this? even if it means completely reworking the logic/idea?