How to do it...

Carry out the following steps:

  1. First, check out how the OSM .pbf file is built using ogrinfo. PBF is a binary format intended as an alternative to the OSM XML format, mainly because it is much smaller. As you must have noticed, it is composed of several layers—you will export the lines layer to PostGIS as that layer contains the street names that you will use for the overall geocoding process:
      $ ogrinfo lazio.pbf        Had to open data source read-only.        INFO: Open of `lazio.pbf'          using driver `OSM' successful.      1: points (Point)      2: lines (Line String)      3: multilinestrings (Multi Line String)      4: multipolygons (Multi Polygon) 
      5: other_relations (Geometry Collection)
  1. Export the lines' OSM features to a PostGIS table, using ogr2ogr ...

Get PostGIS Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.