Converting ordnance survey coordinates into templates within wikipedia markup
September 15, 2011 at 12:10 am Leave a comment
Use the following script (Uses osgb from pypi)
#!/usr/bin/python
import osgb.convert
import sys
import re
def convert(x):
long, lat = osgb.convert.osgb_to_lonlat(x.group(0))
return '%s ({{coord|%.3f|%.3f|source:enwiki-osgb36(%s)}})' % (x.group(0), lat, long, x.group(0))
data = sys.stdin.read()
print re.sub('[A-Z][A-Z][0-9]{6}', convert, data)
Advertisement
Entry filed under: Uncategorized. Tags: .
Trackback this post | Subscribe to the comments via RSS Feed