Skip to content

glynnbird/postcodelookup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postcodelookup

A simple library that allows a postcode to be converted into its latitude and longitude.

This repository contains the code to:

  • convert the Office for National Statistics postcode file into suitable data files.
  • lookup a given postcode to provide its latitude & longitude.

No databases, just files.

Prepare

git clone https://github.com/glynnbird/postcodelookup.git
cd postcodelookup
npm install

Setup

Download the latest postcode lookup data from the Office for National Statistics.

Unzip the download and look in the directory structure for a large CSV file e.g. NSPL_FEB_2020_UK/Data/NSPL_FEB_2020_UK.csv - we need this file for our setup process.

Run setup.js passing in the path to that CSV file to do a one-off setup process e.g:

./setup.js ~/Downloads/NSPL_FEB_2020_UK/Data/NSPL_FEB_2020_UK.csv

Use

In your code:

const lookup = require('.')
lookup('w1a1aa')
// { pc: 'W1A 1AA', lat: '51.518561', long: '-0.143799' }

About

A library to allow fast geocoding of UK postcodes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published