Yet Another Awesome Geo-coder — Open Sourced Spatial Search
By: Mohammed Ayub
Tags: Spatial Analysis, Mapping, Pelias, Docker, Geocoding

What if you collect very large amounts of spatial information such as millions of addresses annual that should be used for geographic analysis but are skeptical of using commercial geo-coders (like Google, HERE, ESRI etc.) or are discouraged by the slow speed of many open source like PostGIS TIGER Geo-coder. There’s a good, if still imperfect, alternative to these options in the works called as “Pelias”. Initially started by some amazing people from Mapzen before that company folded, Pelias now a part of Linux Foundation Project.

Geo-coding at its roots is searching through known addresses or geographies (called ‘shapefiles’, in geeky terms) to find the best match (a Latitude/ Longitude) for a given input address. Pelias makes this possible by indexing globally shared spatial data from various sources into a database called Elastisearch which basically allows for spatial search on steroids !!

You might have come across previous medium posts from Postzen team about setting up Pelias Instance and the progress the project has made since its inception in early 2015 (or before). If your wondering why write another post, there are couple of reasons. Firstly — the entire platform can now be run on top of docker containers that involves much simpler steps to setup than before. The Docker approach raises a host of new questions, and this blog will hopefully address these issues and provide some solutions. It’s a bit of a lengthy read, but it will be worth your time.

The easiest (and the recommended) way to setup Pelias currently is through Docker containers. In early 2017, Pelias decided to break up its API modules into different micro-services and multiple GitHub repositories for different data import pipelines, which makes it look like a daunting task to understand and set one up. By using the new Docker setup you don’t have to worry about most of the gory details of setting-up each micro-service individually or running into serious issues while downloading data for specific regions of interest.

Getting the prerequisites out of the way !!!

System Requirements:

1. Spin up the EC2 instance —

Since Pelias Geo-coder supports from multiple countries, the specs here might vary on how much data you need to download and what region you are interested in. (At-least 8 GB and 300 GB storage recommended).

I have used this AMI (ami-0653e888ec96eab9b) Ubuntu 16.04 /SSD Volume Type with m5a.xlarge and 300GB of storage. (Scale Up/Down as necessary)

(Optional) Creating a Cloud9 Environment for development — You don’t necessarily require this section. As an alternative you can just SSH from any available client (such as Putty etc.)

Install NodeJs on your created instance for Cloud9 — https://tecadmin.net/install-latest-nodejs-npm-on-ubuntu/.

Install NodeJS on Instance



sudo apt-get install nodejs

node -v

npm -v

which node

#Copy this path for later (usually it’s /usr/bin/node)

sudo mkdir cloud9

#Optionally Set the working directory for Cloud9 (Default would be /home/ubuntu if not set) curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -sudo apt-get install nodejsnode -vnpm -vwhich node#Copy this path for later (usually it’s /usr/bin/node)sudo mkdir cloud9#Optionally Set the working directory for Cloud9 (Default would be /home/ubuntu if not set)

In your AWS Management Console, search for Cloud9

Select Create Environment

Enter name and description

Select Connect to remote server (SSH) option.

Enter Username and Host Name of instance created in previous step.

Copy the Public SSH key into the Ubuntu Instance.

Add the NodeJS binary path which we copied earlier.

Click Next and Continue. It should open up new Cloud9 tab which will ask you to install a few requirements before you start using it. It will take some time to install the Cloud9 IDE in your environment.

When it prompts “Installation Completed” Click Finish.

You should be presented now with the Welcome Tab.

2. Install docker and docker-compose

(There is always a DigitalOcean Blog for these kind of things, however below steps worked for me)

Install Docker and Docker Compose



sudo add-apt-repository “deb [arch=amd64]

sudo apt-get update

apt-cache policy docker-ce

sudo apt-get install -y docker-ce

sudo systemctl status docker

sudo docker info

sudo docker run hello-world

sudo curl -L

sudo chmod +x /usr/local/bin/docker-compose

docker-compose — version curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”sudo apt-get updateapt-cache policy docker-cesudo apt-get install -y docker-cesudo systemctl status dockersudo docker infosudo docker run hello-worldsudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-composesudo chmod +x /usr/local/bin/docker-composedocker-compose — version

— — — This brings us to the end of Prerequisites for Pelias — — —