Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install oscodepoint

How to install oscodepoint

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install oscodepoint
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1.1
0.1.2Never BuiltWhy not?
0.1.1 Available View build log
0.1-7-ga199 Available View build log
0.1-4-g773b Available View build log
Windows (64-bit)
0.1.1
0.1.2Never BuiltWhy not?
0.1.1 Available View build log
0.1-7-ga199 Available View build log
0.1-4-g773b Available View build log
Mac OS X (10.5+)
0.1.1
0.1.2Never BuiltWhy not?
0.1.1 Available View build log
0.1-7-ga199 Available View build log
0.1-4-g773b Available View build log
Linux (32-bit)
0.1.2
0.1.2 Available View build log
0.1.1 Available View build log
0.1-7-ga199 Available View build log
0.1-4-g773b Available View build log
Linux (64-bit)
0.1.2
0.1.2 Available View build log
0.1.1 Available View build log
0.1-7-ga199 Available View build log
0.1-4-g773b Available View build log
 
Dependencies
Imports
Lastest release
version 0.2 on Feb 8th, 2012

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 data, 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?

Postcode entries have a Admin_country_code field. Doc/Codelist.xls maps these codes to county names, and codepoint.codelist can be used to access this file. 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

Get the total number of postcodes for your progress bar:

>>> from oscodepoint import open_codepoint
>>> codepoint = open_codepoint('codepo_gb.zip')
>>> print codepoint.metadata['area_counts']['NR']
22730
>>> print codepoint.metadata['total_count']
1692241

Subscribe to package updates

Last updated Feb 8th, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.