This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

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

0

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.


Edit: The following query looks close to what I need. Is it the right way to find the city/town a point lives in?

//How to also search for _nodes_ in just one query?

way["place"~"(city|town)"](around:500,50.540853270068986,8.048780365649707,50.53106288705902,8.030823236553783);

(._;>;);

out meta;

asked 14 Sep '21, 15:49

Shohreh's gravatar image

Shohreh
85131318
accept rate: 0%

edited 15 Sep '21, 11:32

Source code available on GitHub .