Hello, I have a GPS coordinates list and I want to retrieve the corrisponding cities. I'm making calls to Nominatim service, like this: https://nominatim.openstreetmap.org/reverse?format=json&lat=30.4573699&lon=-97.8247654 The response in this case is:
So I can just get the value of According to this answer, I see that I can get other properties, such as Can you make a list of these properties, ordered by frequency or relevance? In addition, what about places that doesn't have any address property? Here is some examples: http://nominatim.openstreetmap.org/reverse?format=json&lat=19.2954697&lon=-99.1545323 http://nominatim.openstreetmap.org/reverse?format=json&lat=28.7146224&lon=77.1577398 http://nominatim.openstreetmap.org/reverse?format=json&lat=33.2038405&lon=-96.7436876 http://nominatim.openstreetmap.org/reverse?format=json&lat=28.7131567&lon=77.1466021 http://nominatim.openstreetmap.org/reverse?format=json&lat=32.2327348&lon=-81.4502764 http://nominatim.openstreetmap.org/reverse?format=json&lat=35.851869&lon=-79.0196451 http://nominatim.openstreetmap.org/reverse?format=json&lat=19.3709484&lon=-99.1666932 https://nominatim.openstreetmap.org/reverse?format=json&lat=51.6185115&lon=-0.7130883 How to deal with them? Generally speaking, what is the best strategy to ALWAYS get a city from GPS coordinates? asked 01 Mar '19, 16:24 Andreanovenove |
The ALWAYS isn't possible. You might get close, but unless you change the definition of city you have to deal with empty data in your data model.
https://wiki.openstreetmap.org/wiki/Key:place lists the place types and the right columns of the table have global counts. https://github.com/OpenCageData/address-formatting/blob/master/conf/components.yaml has a hierarchy of fields relevant for an address. https://github.com/openstreetmap/Nominatim/blob/master/lib/ClassTypes.php is Nominatim's internal logic to assign field names. I would use the components.yaml, look for city aliases and if empty in the Nominatim response move up the hierarchy (county, state...). answered 01 Mar '19, 17:04 mtmail Thank you for your reply, I really appreciated it. Can you tell me what is wrong with places like this https://nominatim.openstreetmap.org/reverse?format=json&lat=51.6185115&lon=-0.7130883 ? As you can see the only reference for place is country! Why?
(02 Mar '19, 14:13)
Andreanovenove
1
That might be an issue with the Nominatim logic. Can happen in remote areas (no addresses in 20+ km radius or such) but shouldn't happen in dense populated areas. Add &zoom=16 to the URL since you said you don't need housenumber level data. Even zoom=10 might work for you. The parameter is explained here http://nominatim.org/release-docs/latest/api/Reverse/
(02 Mar '19, 22:44)
mtmail
It doesn't do the trick. I get "city" with default zoom (18) from here https://nominatim.openstreetmap.org/reverse?format=json&lat=52.5332647&lon=13.2065231, but not with zoom 10. Besides, I get no city, at any zoom level, with other GPS coordinates, like this https://nominatim.openstreetmap.org/reverse?format=json&lat=-1.8292911&lon=99.2568908
(03 Mar '19, 16:40)
Andreanovenove
OpenStreetMap doesn't have enough data for that area. There isn't even a street mapped yet. https://nominatim.openstreetmap.org/reverse?format=html&lat=-1.8292911&lon=99.2568908
(03 Mar '19, 17:12)
mtmail
Ok, I see. What do you think about the first link? Giving different zoom level doesn't always do the trick. Sometimes is convenient to use default zoom because level 10 doesn't return any city field, other times is better to use other zoom level, like 10, to get the city because default level doesn't contains any city field. So, there isn't a rule that I can follow to retrieve always an address field that is city or similar (similar administrative level).
(03 Mar '19, 19:10)
Andreanovenove
Berlin is one of cases with conflicting information. https://www.openstreetmap.org/node/240109189 is tagged as both admin_level=2 (state) and place=city and that confused the reverse geocoding.
(03 Mar '19, 20:09)
mtmail
showing 5 of 6
show 1 more comments
|