Skip to content

Instantly share code, notes, and snippets.

Created May 10, 2012 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2655895 to your computer and use it in GitHub Desktop.
Save anonymous/2655895 to your computer and use it in GitHub Desktop.
veritag: rough and ready OSM (node) data verification tool
507725647 54.9877 -7.3402 m
317491761 -18.9188 47.5393 r
812456308 58.4608 6.0022 ?
1727895329 51.4528 -2.4988 m
310722620 -37.7124 176.1159 r
253506673 51.3150 7.0651 m
1567264697 43.8217 18.3684 ?
1740680283 50.0773 8.8472 ?
29825874 54.9747 -1.6482 r
49213414 39.2664 -77.3092 tc
1638473887 47.3554 8.5597 m
1632491128 51.5410 7.1051 m
65595475 37.3245 -122.0196 r
1144973301 -15.2433 -40.2451 ?
346142705 41.5393 2.1125 j
432296316 31.9208 35.1761 ?
338983487 39.2425 -0.9402 j
895465683 52.7814 -1.5795 m
267153839 55.0446 10.5756 ?
561180600 45.9339 4.8230 r
1286253334 45.7402 7.3276 ?
304692254 48.5289 8.0835 ?
28990510 55.8202 -4.1232 m
261634261 45.7982 4.8037 r
95994361 26.1839 -80.1023 tc
309692518 55.3802 13.1538 ?
1138417549 36.0112 -115.2652 r
726931890 32.8828 -79.8223 tc
279099562 46.4264 6.2699 m
294931559 55.0132 -1.4493 r
675149537 36.8972 54.0428 tc
1672351551 23.1182 113.2931 m
1587711466 54.5423 -6.7775 ?
256786440 -31.5270 27.6937 r
702995995 47.2681 -1.4448 m
34659287 45.1203 -93.3446 tc
177350224 39.5343 -105.3031 tc
356072820 49.1741 -123.1880 r
516650992 40.9487 -5.6424 m
57784567 38.0554 -122.0391 j
303093 51.4707 -0.3285 m
1423118892 43.4618 -1.5463 m
1157811908 -6.2796 106.6591 ?
671559828 45.5806 8.0608 j
291659633 46.7777 7.1561 ?
278024613 51.5569 -1.7737 m
825291942 51.7525 9.4071 tc
1556522433 43.6156 3.8436 tc
447005918 21.3269 103.9145 ?
547975403 34.9526 137.9381 ?
268368202 51.4567 -1.0440 m
835518284 45.5468 10.7323 r
1191042927 51.4800 0.2833 m
612902920 -22.8667 -43.4830 tc
177843328 39.4545 -105.4650 tc
836648004 26.0817 50.0112 ?
1573924838 45.7839 12.4937 r
1591481768 51.4999 7.6209 m
285049142 51.5176 -0.6368 tc
1557696624 46.7780 4.8395 tc
425088321 51.4595 -0.9964 parking
16611127 52.5209 -1.7858 m
53101220 37.7840 -122.1931 tc
21580257 51.7485 -0.3007 tc
1603646435 38.4083 16.0787 r
49334582 32.8941 -117.2374 r
568283770 56.1948 -3.1913 m
649984254 36.9883 -122.0277 r
1727853535 45.7799 12.4942 r
256579486 50.7310 4.4953 r
1251718607 48.5629 16.0737 j
802370221 11.0009 76.9701 r
628125311 43.5605 12.1163 m
660847669 38.3698 -77.4671 tc
246179121 42.6199 2.4282 m
314675362 51.9025 0.9005 m
25640853 53.8082 -3.0245 m
29876262 52.4359 -1.7993 m
268344202 48.9404 2.6688 r
184617665 42.7036 -84.4342 r
515833284 39.9314 4.1384 r
1583660734 52.3511 -1.3972 m
65654441 37.2537 -121.7919 tc
18345407 51.8667 -0.1841 r
29719320 55.8407 -4.4226 tc
1669640893 31.0212 121.4271 tc
672664991 38.3802 -0.4241 parking
1705583089 33.3720 -112.0424 tc? island traffic calming of some sort
14558402 52.6695 -0.7267 m
386231801 14.8976 -92.2531 j
136193687 51.3407 -2.1998 m
41372733 47.8093 9.6398 j
280138309 52.5179 -1.8036 m
932267329 43.5313 1.4903 j
1529483540 47.2977 -2.3998 r
321519412 45.6933 11.4281 j
1651534905 43.8103 4.3242 tc
1568903487 50.2287 -5.2749 m
1715840097 46.0865 1.1226 m
25373409 48.5288 11.5087 j
#!/usr/bin/python
# veritag.py - rough and ready OSM (node) data verification tool.
# 2012-05-10 Andrew Chadwick a.t.chadwick at gmail.
# https://creativecommons.org/publicdomain/zero/1.0/
#
# Generates a random sampling of OSM data (nodes only right now), then fires up
# Bing Maps showing aerial imagery in a running Firefox session and prompts for
# classification of each of the things seen. Should work well with the windows
# side by side. For the classifications, make up your own strings, or use
# numbers.
#
# Input can be overpass API dumps (for example).
#
# Output is a CSV file.
from xml.dom import pulldom
import random
sample_size = 100
bing_uri_pattern = 'http://www.bing.com/maps/?v=2&cp=%0.5f~%0.5f&lvl=20&sty=a&eo=0'
# TODO: expand to ways and closed ways. I guess for a closed way you'd want to
# show the centroid of the convex hull, or the centre of the bbox or something.
def load_osm_file(filename, nodes):
events = pulldom.parse(filename)
for event, domnode in events:
if event == "START_ELEMENT" and domnode.tagName == "node":
# events.expandNode(node) # as necessary
lat = domnode.getAttribute("lat")
lon = domnode.getAttribute("lon")
id = domnode.getAttribute("id")
nodes.append((id, lat, lon))
def browse_uri(uri):
os.system("firefox '%s'" % (uri,))
if __name__ == '__main__':
import os, sys
nodes = []
usage = "%s OUTPUT.csv INPUT1.osm [INPUT2.osm ...]"
script = sys.argv[0]
if len(sys.argv) <= 2:
print usage % (script,)
sys.exit(1)
outfile = sys.argv[1]
infiles = sys.argv[2:]
print "Will write classifications to %s" % (outfile,)
for f in infiles:
print "Loading %s..." % (f,)
load_osm_file(f, nodes)
print "Loaded all files."
print "Writing classifications to %s" % (outfile,)
out_fp = open(outfile, "w")
s_num = 1
for id, lat, lon in random.sample(nodes, sample_size):
id = int(id)
lat, lon = float(lat), float(lon)
uri = bing_uri_pattern % (float(lat), float(lon))
browse_uri(uri)
cls = raw_input("Classification for id=%s (%d/%d)? " \
% (id, s_num, sample_size))
print >>out_fp, "%d,%0.4f,%0.4f,\"%s\"" % (id, lat, lon, cls)
out_fp.flush()
s_num += 1
out_fp.close()
print "%s written." % (outfile,)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment