OpenStreetMap

Nominatim (from the Latin, ‘by name’) is a tool to search OSM data by name and address and to generate synthetic addresses of OSM points (reverse geocoding). Using Geocoder you can retrieve OSM’s geocoded data from Nominatim.

Geocoding

>>> import geocoder
>>> g = geocoder.osm('New York city')
>>> g.json
...

This provider may return multiple results by setting the parameter maxRows to the desired number (1 by default). You can access those results as described in the page ‘Access to geocoder results‘.

Nominatim Server

Setting up your own offline Nominatim server is possible, using Ubuntu 14.04 as your OS and following the Nominatim Install instructions. This enables you to request as much geocoding as your little heart desires!

>>> url = 'http://localhost/nominatim/'
>>> url = 'localhost'
>>> g = geocoder.osm("New York City", url=url)
>>> g.json
...

OSM Addresses

The addr tag is the prefix for several addr:* keys to describe addresses.

This format is meant to be saved as a CSV and imported into JOSM.

>>> g = geocoder.osm('11 Wall Street, New York')
>>> g.osm
{
    "x": -74.010865,
    "y": 40.7071407,
    "addr:country": "United States of America",
    "addr:state": "New York",
    "addr:housenumber": "11",
    "addr:postal": "10005",
    "addr:city": "NYC",
    "addr:street": "Wall Street"
}

Command Line Interface

$ geocode 'New York city' --provider osm --out geojson | jq .
$ geocode 'New York city' -p osm -o osm
$ geocode 'New York city' -p osm --url localhost

Parameters

  • location: Your search location you want geocoded.

  • url: Custom OSM Server (ex: localhost)

  • maxRows: (default=1) Max number of results to fetch

  • limit: Deprecated, same as maxRows

  • method: (default=geocode) Use the following:

    • geocode