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

Reverse geocoding API by nominatim is giving inconsistent result

0

Hello all,

I'm trying to get value of the key "city" using latitude and longitude. But unfortunately, I'm not getting expected result most of the time.

For example, the following API is giving correct value of city ("Dhaka"): https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=23.7123823525915215&lon=90.4103022068739&zoom=18

On the other hand, this API is not giving any value of city, whereas both of the locations are from same city: https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=23.76615&lon=90.35673&zoom=18

Any suggestion on how to get more consistent result?

asked 20 May '18, 11:18

shamimabrishti's gravatar image

shamimabrishti
16112
accept rate: 0%


One Answer:

2

It's a data coverage issue in this case. The city of Dhaka is in OSM data https://www.openstreetmap.org/node/3442474911, but it doesn't have (administrative) boundaries, so Nominatim simply doesn't know how big it is. The center point of the city (that node) is too far away to make a guess. Somebody (that could be you, https://www.openstreetmap.org/fixthemap) needs to change the OSM data to add boundaries.

An alternative is to add 'is_in' tags https://wiki.openstreetmap.org/wiki/Key:is_in to the suburbs. So is_in:city=Dhaka to (1) Pisciculture Housing (2) Mohammadpur (3) Mohammadpur Future Town. I got the names of the nearby suburbs from https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=370027291

answered 20 May '18, 21:28

mtmail's gravatar image

mtmail
4.8k1574
accept rate: 27%

Thanks a lot @mtmail for your effort, it was really helpful. I'll work on your suggestion :)

(21 May '18, 09:29) shamimabrishti

Source code available on GitHub .