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

Import data to Nominatim for reverse geocoding API purpose only querying up to city level

0

I am building a Nominatim server which will serve as reverse geocoding api server. Only city/state(province)/country information are required in the api result. The street/road level information are not required.

For example, the server will give result: http://localhost/nominatim/reverse?lat=43.815031&lon=-79.716834

{ city:Brampton; state:Ontario; country:Canada }

I would like to use osmosis to filter the data before I import the whole planet data. What command line should I use for this purpose? How about the one below? Thank you.

filter relations by administrative

osmosis --read-pbf planet-latest.osm.pbf --tf accept-relations boundary=administrative --used-way --used-node --lp --write-pbf import1.osm.pbf

filter ways by administrative

osmosis --read-pbf planet-latest.osm.pbf --tf accept-ways boundary=administrative --used-node --tf reject-relations --lp --write-pbf import2.osm.pbf

merge all files together

osmosis --read-pbf import1.osm.pbf --read-pbf import2.osm.pbf --merge --write-pbf import.osm.pbf

This question is marked "community wiki".

asked 23 Nov '16, 18:48

CQG's gravatar image

CQG
11113
accept rate: 0%

edited 23 Nov '16, 19:43


One Answer:

1

You should also include all nodes/relations with the place tag because in countries with less coverage cities are often just nodes without boundaries.

http://taginfo.openstreetmap.org/keys/?key=place#values Not all values are interesting, try 'state','county','district','city','territorial','town','island'

answered 24 Nov '16, 11:08

mtmail's gravatar image

mtmail
4.8k1574
accept rate: 27%

Good point. Thank you so much.

(24 Nov '16, 15:54) CQG

Source code available on GitHub .