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

I am trying to find neighbouring cities of a city/state.

0

I am very new to overpass api. I am trying to find a way to get nearby cities. i,e if I enter a city or a state, I should be able to get cities within that input area. And as an option, I want to filter the results for a specific country. I have tried several ways. But none of them seems to work.

[out:json];area["name"="India"][admin_level=2];area["name"="Kerala"]["border_type"="state"];(node["place"="city"]["name"="Cochin"](area);)->.center;node(around:10000)["place"];out;

Here India is the country Kerala is a state of the country And Cochin is a city inside that state. So I am trying to find the nearby cities of Cochin

asked 10 Apr '19, 17:08

zudheer's gravatar image

zudheer
11112
accept rate: 0%


One Answer:

0

Hi Zudheer, you might want to take a look at overpass-turbo, it has a wizard (see menu-button on the top) which translates easy words to queries, great for experimenting and learning. I'Ve made you a quick example here ->

https://overpass-turbo.eu/s/HSo

On a little side-note, I think it'S safe to say this code:

  node["place"="city"](area.searchArea);
  way["place"="city"](area.searchArea);
  relation["place"="city"](area.searchArea);

can be shortened by:

nwr["place"="city"](area.searchArea);

Hope it helped!

answered 10 Apr '19, 18:08

tijmenheid's gravatar image

tijmenheid
415511
accept rate: 0%

Source code available on GitHub .