1

I would like to intercept a specific log coming from overpass api and perform a retry of the function. When using

import osmnx as ox
ox.settings.log_console = True

I see the messages i.e. :

2025-05-28 09:14:32 Resolved 'overpass-api.de' to '65.109.112.52'

2025-05-28 09:15:52 Downloaded 0.4kB from 'overpass-api.de' with status 200

2025-05-28 09:15:52 'overpass-api.de' remarked: 'runtime error: Query run out of memory using about 4838 MB of RAM.'

2025-05-28 09:15:52 Retrieved 0 elements from API in 1 request(s)

if the runtime error is present, I need to block the run and perform a retry of a function. is there a way to access this log console? This is not a return of a function of osmnx, but it is coming from the API and is a general setting. I could not find any example on the python library documentation.

1 Answer 1

1

Saving your log and fixing your memory issue can both be achieved by OSMnx's settings module.

how to access log messages when retrieve features

Use ox.settings.log_file to write the log to disk (and optionally read/process it further).

runtime error: Query run out of memory using about 4838 MB of RAM

Use ox.settings.overpass_memory to configure the server's memory allocation or ox.settings.max_query_area_size to subdivide large queries into smaller sub-queries for the server to handle it better.

If you are indeed getting 0 elements back from the API, you should receive an InsufficientResponseError, which you can catch/handle.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your tips gboeing. I used the max_query_area_size, and added similar function in the code, but i still have the same error. And most weirdly , I got all other features I need except one (highway=residential), even if I use a 10x10km square as aoi, where there should be less than 100 features. I read the code github.com/gboeing/osmnx/blob/main/osmnx/_overpass.py but still I don't understand why with a such small area I got this error.
I see as well that before receiving the final geodataframe ("219 features in the final GeoDataFrame") happens this "Retrieved 1,624 elements from API in 1 request(s)" : why such difference?
you did not provide a complete, minimal, reproducible code snippet, so we cannot guess. If this question (how to access logs) is answered, you may wish to mark it as such and then ask a new question with complete reproducible details so this community can troubleshoot.
sure, you are right. here it is: stackoverflow.com/questions/79671314/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.