Where does Nominatim get its address info? - openstreetmap

Till now, I was using the Nominatim API to fetch landmark information from but recently, I've downloaded the OpenStreetMaps database, and tried to make my own dataset, so I would not rely so heavily on Nominatim services. I managed to extract from the OSM database the needed information (nodes tagged with amenity for example), but I realized, that while I was querying for amenities through Nominatim, it returned a bunch of address info, which is nowhere to be found in the OSM database.
Example:
Reverse geocoding of a hotel from Spain using Nominatim:
http://nominatim.openstreetmap.org/reverse?format=xml&osm_type=N&osm_id=1207098527
The data that is attached to the same node used to reverse geocode in OSM:
http://open.mapquestapi.com/xapi/api/0.6/node/1207098527
While Nominatim gives me Suburb, Pedestrian, City, County, State, etc. information, this node in OSM contains only a name tag, and a tourism tag.
Does anyone know, where is Nominatim getting the additional data it uses to display its information from?

Nominatim does not just look at individual objects but gathers information from multiple objects instead. Look at the information Nominatim knows about "HOTEL LA MORADA MAS HERMOSA": There are:
the node, lacking all address information (feel free to improve this!, at least house number and street should be added)
a nearby street
the suburb the hotel is located in
the city
... and so on.
Remember, OSM is a spatial database. Instead of attaching all information to each individual object one can do spatial queries in order to gather various kinds of additional information.

Related

How to store locations in ArangoDB?

I am building a web application where I need to store a large number of unique addresses as nodes in ArangoDB.
One approach would be using a hierarchical graph model: a country node connected to county nodes, county nodes connected to cities and cities connected to exact addresses with GeoJSON attributes.
The other option would be having only address nodes which contain city, county and country as attributes.
Which method would be more beneficial? I would be running queries to find locations in a given range or locations in a given city.
Well, let's see what you will need in terms of collections to build your app:
Collection storing the Places you want to use in your app. This would be your main collection and would contain among other things a map location object {longitude: XXX, Latitude YYY}
Because you probably want people to be able to search by city, country, etc.. You need either a collection per Location type (city, country, etc) or a table with all the locations and a "type" flag that indicates the location is city or country, etc....
3.- You need a table that allows you to start at a country and drill down to a particular set of cities (for example). So, you need a table with a from key and a to key
By this point you probably have noticed that we have basically built a hierarchy, which in Arango I would build as at least one Places vertex collection, a Locations vertex collection and a locationContains edge collection. This would allow for really fast lookups and is one of the reasons why graph databases were originally created.
Now note that since Arango is a multi model DB, you can use the graph syntax (I like anonymous graph syntax myself), but you can also use traditional joins whenever needed, which behave very similar to a traditional relational DB.

need a list for all countries with their states and cities including latitude and longitude

I am creating an App which needs data for countries, states and cities which is available at lots of places but here for some reason I need to know the latitude and longitude of each country including its state and city. From which one source can I find all these? I need to store this data in mongoDb.
I tried downloading allCountries.zip file from here GeoNames but I found that data is not in proper tsv format and it's very complicated to get the expected output data from here.
Is there anything else from which I can get the desired result?
Please help if anyone knows
Thanks a lot in advance :)
There is a webservice provided by geoNames which gives all the information about countries, states and cities.
http://ws.geonames.org/childrenJSON?geonameId=8505026&username=demo
this is an API which gives children i.e if you provide countries geonameId then it will give its states. If you provide states geonameId it will give its cities.
So in that way we can have all the information about countries states and cities. To get all geonameId of countries for that they have provided another API
http://api.geonames.org/countryInfoCSV?username=demo
There is just one thing we should keep in mind that for username we have to create an account and whose credit limit is approx 2000 per day. So if we want to hit the API more than 2000 a day we have to create another account :)
Pretty good thing and very useful thing provided by geoNames

How to get all place name translations in Nominatim?

OpenStreetMap supports different name translations for places. For example "Moscow" in English and "Москва" in Russian for the same node. But there are also French, German, Bahasa translations and so on. Is there a way to get all these translations in a single request? I know I can use "accept_language" property on a "reverse" request, but in will only return a single translation, and I'd like to get all available translations in one request. Fast googling didn't return any results. Thank you.
Use the osm_type and osm_id fields to retrieve the original OSM element.
Example: The Nominatim query for Moscow will return osm_type: relation and osm_id: 2555133 for the first result. Based on this information we can look at the original OSM element or perform an OSM API query for this element. This will include all name:<lang> tags.
Note: Make sure to look both at the Nominatim usage policy and OSM API usage policy before running automated queries!

How to do Geo IP or postcode lookup against Geonames data

I am using the freely available geonames data locally to do autocomplete searches during the sign up stage on one of my websites.
I am having trouble working out the best way to make the form more user friendly by auto selecting a geoname based on their IP address and also be able to lookup a geoname based on the postcode data.
The problem is that I can't see a way to easily link an IP range or a postal code to a geoname. So what is the best practice here? Do I just run a separate query to lookup the nearest geoname by long/lat against the postcode or IP address?
You don't mention how you are geolocating the IP address, but the MaxMind GeoIP2 and GeoLite2 databases provide the geoname_id of the location. See, e.g., the CSV docs. The binary databases provide this same information.

Feed JSON to Nominatim with import.io

Greetings fellow SO users,
I am extracting data with import.io from a site which contains city names. What I want to accomplish is to get the coordinates to each city from Nominatim and finally create/get a JSON response which contains the city name and the corresponding coordinates for each.
So I basically need to use the result from one API as the input for another (Nominatim).
Or in other words: feed a JSON list of city names to OSM's Nominatim and get back the coordinates to each city.
I wonder if this is even possible or what other options I have. Finally this would be used with leaflet to put some markers at a map.
There are tutorials for Nominatim, how to query etc. but only one query at a time. Is it even possible to query a whole list of places?
What you want to achieve in here is what we call Chained APIs. So you will need two APIs, where the input of the second one is the output of the first one.
In this case you will need some custom processing between the two APIs. From the first API you are getting the city name and from here you need to generate a list of URLs in the format http://nominatim.openstreetmap.org/search?q=CITY&format=xml one per each CITY.
After that you can use the Bulk Extract feature in import.io and pass the whole list of URLs to be queried against the API.