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

SQL query for house numbers

2

Hi,

I've imported the tiger database and i now have house numbers in nominatim. I am trying to get a list of all house numbers on a street. Currently I am iterating through numbers using the local nominatim API to get the highest number but that is very inefficient.

How would I get a list of house numbers using SQL? I am thinking it would be something like:

SELECT house_number, latitude, longitude FROM table WHERE street = "10th street NW, Washington";

Regards, Bob

asked 21 Jun '14, 13:36

bob12's gravatar image

bob12
41113
accept rate: 0%


One Answer:

2

There is currently no documentation available (at least not on the OSM wiki) describing the database schema nominatim uses. To get around this you either need to have a look at the scripts that create the database or alternatively use psql and the \d command to get a list of tables and then \d tablename to get the columns. If you do that, it would be a good idea to put the results of your research on the wiki :-).

answered 22 Jun '14, 12:07

SimonPoole's gravatar image

SimonPoole ♦
44.7k13326701
accept rate: 18%

1

OK this looks to be getting me on the right path: $pgsql nominatim $pgsql> SELECT * FROM points WHERE street = 'xyz street';

Will return all house numbers and coordinates I'll Write up a better query and add it to the wiki if it works out well

(22 Jun '14, 13:18) bob12

Source code available on GitHub .