Ordnance Survey的CodePoint-Open数据的Python接口
项目描述
Ordnance Survey的CodePoint-Open的接口。CodePoint-Open是一个免费的地图数据集,将英国邮政编码映射到坐标。
oscodepoint读取此数据,无论是在原始zip文件中还是在解压缩后,解析数据,并将网格参考转换为纬度和经度。
数据集可以从http://www.ordnancesurvey.co.uk/oswebsite/products/code-point-open/下载
示例
>>> 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
数据量太大?尝试限制邮政编码区域
>>> 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
需要邮政编码所在的县?
邮政编码条目有一个Admin_country_code字段。 Doc/Codelist.xls将这些代码映射到县名,而codepoint.codelist可以用来访问此文件。例如
>>> 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
获取邮政编码总数以供进度条使用
>>> from oscodepoint import open_codepoint >>> codepoint = open_codepoint('codepo_gb.zip') >>> print codepoint.metadata['area_counts']['NR'] 22730 >>> print codepoint.metadata['total_count'] 1692241
项目详情
关闭
oscodepoint-0.3.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 30c2e910623667ee6600753dabc8e6a1879cd34aa0089bc67f12438ac38a281d |
|
MD5 | de58aa049e04aec7960b2cc7d579075e |
|
BLAKE2b-256 | 24800367f21bd97ab2321c5645b1997737673c48536b037147ee5a8d95813b6d |