Part 1 | Part 2 | Part 3

Overview:

The base Open Street Maps (OSM) planet files shall not contain street/house address numbers for the United States.

If you are looking for this level of resolution in your reverse-geocoding, you will need to supplement Nominatim with the US Census TIGER EDGE files. These data files are separated by state, and essentially provide GIS shape files and respective address information for each house/building and areas included in the Census data set.

NOTE: This Census TIGER EDGE data-set discussed may not include address information for commercial buildings. These and other entities can be included by incorporating other government GIS data sets and through commercial providers, but these are out of scope for this article.

Prerequisites:

  • Prepared OSM Nominatim CentOS system, as described in Part 1 and Part 2 articles.
  • Time and patience, as interacting with the government FTP server will take some time, and loading the data into Nominatim shall take about half a day.
  • See disclaimer

1. Downloading the Census Data

  1. It is assumed that you already have a directory setup to save downloaded Census TIGER files, such as: /opt/nominatim/source_data/census_tiger_edge_files
  2. Go to the US Census TIGER data download site.
    NOTE: The government site will go up/down and may be difficult to connect to. I found connecting after 6PM EST gave me the best performance.
    > https://www.census.gov/geo/maps-data/data/tiger-line.html
    > ftp://ftp2.census.gov/geo/tiger/TIGER2015/EDGES/
    wget -P /opt/nominatim/source_data/census_tiger_edge_files/ ftp://ftp2.census.gov/geo/tiger/TIGER2016/EDGES/* &
    disown
    
  3. Ensure that the linux nominatim user owns everything in the /opt/nominatim path, as this will be the user reading and applying data changes
    sudo chown nominatim:nominatim /opt/nominatim/source_data/ -R

2. Loading the Census TIGER Data

  1. Temporarily turn off SELINUX, as the load script performs both executable, postgresql and library files calls:
    setenforce 0
    
    sestatus
  2. Ensure that PostgreSQL is running:
    systemctl status postgresql
  3. Go to your census Tiger EDGE directory (/opt/nominatim/source_data/census_tiger_edge_files).
  4. Unzipping may take 10 minutes to complete … lots of big files. Remember to CHOWN when done.
    cd /opt/nominatim/source_data/census_tiger_edge_files/
    unzip '*.zip'
    
    chown nominatim:nominatim /opt/nominatim/source_data/ -R
  5. Next step is to parse the EDGE files.This process parses the EDGE files components into a /tmp/tiger directory, and creates a respective SQL import file in /srv/nominatim/Nominatim/data/tiger directory.For example, the tl_2016_46xxxxx_edges files for South Dakota will be parsed into the respective 460003.sql through 460137.sql import files.
    su nominatim
    /srv/nominatim/build/utils/imports.php --parse-tiger /opt/nominatim/source_data/census_tiger_edge_files/YOUR_Edge_File_Subdir 
    
  6. Import EDGE Files (see screen shot below). This process executes the individual created Tiger EDGE SQL import files.

    NOTE
    : You don’t get much feedback from the current imports.php and setup.php Census Tiger process. As shown below, no errors are good news.
    NOTE: The following process can take up to 12 hours for the entire US.
    su nominatim
    /srv/nominatim/build/utils/setup.php --import-tiger-data 
  7. Apply and re-analyze Nominatim core data set (this may take a long while too)
    su nominatim
    /srv/nominatim/build/utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
Importing Census TIGER data into OSM Nominatim

3. Enabling Census TIGER Data in Nominatim

By default, the OSM Nominatim system will not enable the Census data. You must perform the following additional step. Be careful about extra spaces, as described, as this got me a few times.

IMPORTANT Make sure there are no lines or spaces at the beginning of your settings/local.php files. Ensure each @define has a single space before it, and no blank lines between.

  1. Enable use of the Tiger data in your settings/local.php by adding:
    @define(‘CONST_Use_US_Tiger_Data’, true);
    to files:
    /srv/nominatim/build/settings/local.php
    /srv/nominatim/Nominatim/build/settings/local.php
    (note that I created an additional nominatim directory copy)
  2. Ensure nominatim user indeed owns all of these files:
    chown nominatim:nominatim /srv/nominatim/build/settings/ -R
    chown nominatim:nominatim /srv/nominatim/Nominatim/build/settings/ -R

4. Start and stop Apache and PostgreSQL

systemctl stop httpd
systemctl restart postgresql
systemctl start httpd

5. Troubleshooting Installation and Data Load

6. Using OSM Nominatim

 

Hope this helped; yes there are lots of different brews and instructions out there, but this is how I was able to get the system installed and loaded. Associated articles shall perform GET requests to interact with the OSM Nominatim system. paulsDevBlog.End();