Skip to main content

A Python interface to Ordnance Survey's CodePoint-Open data

Project description

An interface to Ordnance Survey’s CodePoint-Open. CodePoint-Open is a free dataset that maps UK postcodes to coordinates.

oscodepoint reads in this data, whether in the original zip or decompressed, parses the dataset, and converts grid references to latitude and longitude.

The dataset can be downloaded from http://www.ordnancesurvey.co.uk/oswebsite/products/code-point-open/

Example:

>>> from oscodepoint import open_codepoint
>>> codepoint = open_codepoint('codepo_gb.zip')
>>> for entry in codepoint.entries():
...    print entry['Postcode'], entry['Latitude'], entry['Longitude']
...    break  # Over 1.6 million rows
AB101AA 57.1482995075 -2.09663094048

Too much data? Try limiting the postcode areas:

>>> from oscodepoint import open_codepoint
>>> codepoint = open_codepoint('codepo_gb.zip')
>>> for entry in codepoint.entries(areas=['NR', 'IP']):
...    print entry['Postcode'], entry['Eastings'], entry['Northings']
...    break
NR1 1AA 624068 308352

Want the postcode’s county?

Try codepoint.codelist, an interface to Doc/Codelist.xls. For example:

>>> from oscodepoint import open_codepoint
>>> codepoint = open_codepoint('codepo_gb.zip')
>>> county_list = codepoint.codelist['County']
>>> for entry in codepoint.entries(areas=['NR']):
...    print entry['Postcode'], entry['Latitude'], entry['Longitude'], county_list.get(entry['Admin_county_code'])
...    break
NR1 1AA 52.6266175146 1.30932087485 Norfolk County

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oscodepoint-0.1.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file oscodepoint-0.1.tar.gz.

File metadata

  • Download URL: oscodepoint-0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for oscodepoint-0.1.tar.gz
Algorithm Hash digest
SHA256 4d37fef29f37368430cad74e7e4f58f7900e6486e9f56491e8e47cc6824ef360
MD5 965ba8403ff7c700bddef223322f6da9
BLAKE2b-256 1a08e36665d5a86cf03afb97b936cf5ebdb35edd1bccd73a57cb1ce92be31940

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page