Skip to content

Instantly share code, notes, and snippets.

@M66B
Last active April 23, 2016 14:04
Show Gist options
  • Save M66B/62480affb192fe4ff229 to your computer and use it in GitHub Desktop.
Save M66B/62480affb192fe4ff229 to your computer and use it in GitHub Desktop.
Convert OpenCellIId database to OSM
import csv
#Database: http://opencellid.org/
#OsmAnd Map Creator: http://wiki.openstreetmap.org/wiki/OsmAndMapCreator (-Xmx1792M)
print "<?xml version='1.0' encoding='UTF-8'?>"
print "<osm version='0.5' generator='M66B'>"
#0 1 2 3 4 5 6 7 8 9 10 11 12 13
#radio,mcc,net,area,cell,unit,lon,lat,range,samples,changeable,created,updated,averageSignal
#UMTS,262,2,801,86355,,13.28527,52.521711,37,7,1,1282569574,1300175362,-91
i = 0
with open('cell_towers.csv', 'rb') as csvfile:
cellreader = csv.reader(csvfile)
for row in cellreader:
i = i + 1
if i == 1:
continue
if row[1] != '716': #PE
continue
print "<node id='" + str(-i) + "' visible='true' lat='" + row[7] + "' lon='" + row[6] + "'>"
print "<tag k='name' v='" + row[0] + " " + row[1] + "-" + row[2] + "-" + row[3] + "-" + row[4] + "'/>"
print "<tag k='man_made' v='tower'/>"
print "<tag k='tower:type' v='communication'/>"
print "<tag k='communication:mobile_phone' v='yes'/>"
print "</node>"
print "</osm>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment