https://github.com/glynnbird/postcodelookup
A library to allow fast geocoding of UK postcodes
https://github.com/glynnbird/postcodelookup
geocode nodejs postcode uk
Last synced: 5 months ago
JSON representation
A library to allow fast geocoding of UK postcodes
- Host: GitHub
- URL: https://github.com/glynnbird/postcodelookup
- Owner: glynnbird
- Created: 2020-04-21T13:12:02.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-21T21:05:35.000Z (almost 6 years ago)
- Last Synced: 2025-10-13T16:45:51.517Z (5 months ago)
- Topics: geocode, nodejs, postcode, uk
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```sh
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](https://geoportal.statistics.gov.uk/datasets/4f71f3e9806d4ff895996f832eb7aacf).
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:
```sh
./setup.js ~/Downloads/NSPL_FEB_2020_UK/Data/NSPL_FEB_2020_UK.csv
```
## Use
In your code:
```js
const lookup = require('.')
lookup('w1a1aa')
// { pc: 'W1A 1AA', lat: '51.518561', long: '-0.143799' }
```