[Bike trip] Script to query OSM and grab list of cities/towns in trip?

Hello,

As a low-fi backup for my smarphone that I use as GPS during bike trips, I’m thinking of printing it on a single page to have a rough idea where I should head using a compass, and run a script that will 1) take the (simplfied down to 500 points) trip as input, 2) query OSM for all the towns and cities along the way, and 3) output the list that I’ll then use as a road book.

Provided Overpass won’t complain with too many queries, would someone have some code to share (ideally Python)?

Thank you.

You can use my blog post as a starting point:

https://www.openstreetmap.org/user/mmd/diary/42055

Same question was also posted here: https://help.openstreetmap.org/questions/81738/bike-trip-script-to-query-osm-and-grab-list-of-citiestowns-in-trip

Thanks much!

You seem to have asked some follow up question on Help OSM. This is a bit confusing and not that helpful for other readers.
I would recommend to stick to one site, rather than spreading your question over two sites.

Because I didn’t know which site was more read, and more likely to get replies.

Incidently, why two sites?

Ok, if you want to query nodes and ways at the same time, you can use “nw” instead of “nodes”. It’s described in more detail here: https://dev.overpass-api.de/blog/total_0_7_56.html#type_shortcuts

I don’t know why we have two sites. As both run on no longer maintained software, they will be replaced anyway by Discourse at some point.

Thank you.