NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I constructed a python query to look for all the bus routes passing by a given box. However, I need to speed up the query as much as possible. I only need the lat/lon coordinates of each node representing the bus stops and the name of the routes that they belong to. My current code:

import requests

overpass_url = ""

bbox = [48.87542724909715, 2.1707384550740683, 48.88884184835508, 2.1821696229817267]
bbox_str = '('+str(bbox)[1:-1]+')'

overpass_query = '''
out body;
out skel;

response = requests.get(overpass_url, params={'data': overpass_query})
data = response.json()

asked 16 Feb '21, 17:51

fragodec's gravatar image

accept rate: 0%

edited 16 Feb '21, 17:53

I don't know if it is more efficient and/or faster but you could search for every bus stop in a given bounding box and then recurse back to the relations that have that stop as member:


// query part for: “highway=bus_stop”

foreach.stops ->.s(

  //get the route (stop must be a member!)

  //produce output
  make stop name = s.u(t["name"]),
  lat = s.u(lat()), 
  lon = s.u(lon()),
  lines = r.set(t["ref"]);

  out meta;     
permanent link

answered 20 Feb '21, 21:26

MarcoR's gravatar image

accept rate: 23%

Thank you for your answer. This works fine but unfortunately it is slower than my code (with the examples I tried).

(22 Feb '21, 11:17) fragodec

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 16 Feb '21, 17:51

question was seen: 1,393 times

last updated: 22 Feb '21, 11:18

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum