How to get a list of streets for a certain populated place?

I am very new with OpenStreetMaps and my feeling is that the learning curve is much too steep.:slight_smile:

What I need concretely, is as follows:
I am trying to extract lists of street names by names of populated places from OpenStreetMap / Overpass using e.g. the following Python code:


import requests

overpass_url = "http://overpass-api.de/api/interpreter"
overpass_query = """
[out:json];
  area
[name="Fulda"];
way(area)[highway][name];
out;
"""

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

In this way I can get more or less everything I need, but the problem is how to avoid the ambiguity with the place names: there is a city in Germany called Fulda and a number or places in the US. The code above returns streets in all of them. Is there a possibility to modify the query so that it filters for just one certain country, e.g. Germany?

PS. I have already asked on Stackoverflow, but got no answer, so I hope here it would be a more appropriate place to ask. TIA, :slight_smile:

Maybe that website can help:

Overpass area query by ID instead of by NAME
https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#By_area_.28area.29

Hi R0bst3r,
thanks a lot, but this entails my next beginner’s question: how should I get the Area ID if I know the name of the populated place and the country? E.g. “Fulda” and “Germany” (or as an ISO country code, “de” or “ger”)? I have played around trying to obtain something like a place id using queroes like

https://nominatim.openstreetmap.org/search?format=json&city=Fulda&country=de

; in the response, you have both osm_id and place_id, but none of them relates to the city (and could thus be used as the area code suggested above) - is that correct?

You can query using more unique identifiers, for example wikipedia or wikidata tag.

Can you link which object you want to search inside?

Hello Mateusz,
and thanks. For instance, the city of Fulda in Germany (not the hamlets of the same name in the US). How can I obtain the wikidata tag? And how do I use it in an Overpass query? Fulda is just an example; I am interested in many places in Europe that have their namesakes in the US and elsewhere. TIA, Stan

You can get the “relation” id for are of Fulda, Germany by searchin on osm.org.
Link: https://www.openstreetmap.org/relation/454863
So your area ID is 454863.

On this relation you can also find wikidata, regionalschluessel, admin_level etc.

You will also get more help in the subforums, maybe in the german? https://forum.openstreetmap.org/viewforum.php?id=14

Hi R0bst3r,
and thanks for your reply. It is really interesting. I understand now that that ID is the so called ‘osm_id’, e.g. if I run the query

https://nominatim.openstreetmap.org/search?format=json&city=Fulda&country=de

I get it there. Thanks a lot, this really helps.

PS. Besten Dank aus Potsdam :slight_smile: Ich bevorzuge Englisch als Websprache: man erreicht mehr Leute :slight_smile: :slight_smile:

Still a last (hopefully) question:
What query do I need exactly to send to get the streets ??


[out:json];
way(area:454863)[highway][name];
out;

This one does not work, nor do my other attempts. The page ‘https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#By_area_.28area.29’ may be a great resource for OSM pundits, but not for an average user (who only needs to use it).
I would be thankful for all hints. Stan.

Even if it is too late: this works if it is what you expected?

[out:json];
area[name="Bonn"];
way(area)[highway][name];
out;

Thanks R0bst3r,
the thing is: there are two places named Bonn: the one upon Rhein and one in Ohio. How can I get the streets only in one of them?

Take a look at https://dev.overpass-api.de/overpass-doc/en/full_data/area.html

@PHerison: What section exactly do you mean? If that ‘Area inside an Area’, replacing ‘London’ to ‘Bonn’ and ‘England’ to ‘Germany’ brings an empty response. Thanks a lot!