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

How do I find the nearest cities to a point using latitude and longitude in nominatim?

1

The thing is I need to know that both moves away from a city and that both approaches another, but the search just gives me the data where it is, I need to do this search the names of the two nearest cities.

http://nominatim.openstreetmap.org/search?q=co+4.17897295000,-73.70788536667&format=xml&addressdetails=1

How do I do this query?

asked 30 Oct '12, 22:29

diegoug's gravatar image

diegoug
26112
accept rate: 0%


One Answer:

2

Nominatim is an address search engine and not really suited for your purpose. You are looking for another kind of search and Overpass API seems to fit a lot better.

Take a look at this example query for all place nodes in the area you mentioned:

http://overpass-api.de/api/interpreter?data=[out:json];node["place"](4.14,-73.73,4.21,-73.67);out;

Note that this query only searches for nodes, you want to search for ways, too, to find every city. If the query doesn't return anything for a specific area, try increasing the given bounding box. You can also choose a different output format, just take a look at the documentation and the examples.

answered 31 Oct '12, 14:56

scai's gravatar image

scai ♦
33.3k21309459
accept rate: 23%

Source code available on GitHub .