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

How can I get the zone administrive of a city from postgis (nominatim import)?

0

I posted on stackoverflow before to find this website. so here is my my post.

http://stackoverflow.com/questions/10242129/how-can-i-get-the-zone-administrive-of-a-city-from-postgis-nominatim-import

I retreived europe.osm database with osm2pgsql. And now I try to exploit it. Is there a way to get the state, country, region, from a way like a town hamlet locality or city?

https://wiki.openstreetmap.org/wiki/Nominatim
https://github.com/twain47/Nominatim

databases osm format :
http://download.geofabrik.de/osm/europe/
here is the database schema :
https://wiki.openstreetmap.org/wiki/Osm2pgsql/schema

if someone can provide me the SQL Query to retreive the information.

asked 23 Apr '12, 15:52

Christophe%20DEBOVE's gravatar image

Christophe D...
16225
accept rate: 0%

edited 24 Apr '12, 08:39

SimonPoole's gravatar image

SimonPoole ♦
44.7k13326701


One Answer:

2

I presume you have a full Nominatim installation as described on the installation page not just an osm2pgsql import.

Doing SQL queries on the database directly is a bit involved. You can get administrative information much easier by sending reverse requests directly to your local installation. If you have the OSM id of your way, send something like: http://your.local.nominatim.server/reverse?osm_type=W&osm_id=<osm id> and process the XML returned.

If you still want to go down the SQL road, have a look at the placex and place_addressline tables. The former contains all OSM objects and the latter the relationship between them.

answered 24 Apr '12, 08:36

lonvia's gravatar image

lonvia
6.2k25789
accept rate: 40%

edited 24 Apr '12, 10:34

thanks I didn't make the full nominatim install because I've allready a geo request system, I need just to make an import to my system.

(24 Apr '12, 09:23) Christophe D...

Sorry but there is not place_addressline table

(24 Apr '12, 10:22) Christophe D...

The placex and place_addressline tables are part of the full Nominatim import. If you don't want to do the full import, there is no point in importing the gazetteer schema in the first place.

(24 Apr '12, 10:40) lonvia

Ok I will follow the full installation. Thx

(24 Apr '12, 13:35) Christophe D...

Source code available on GitHub .