Created
December 9, 2010 00:38
-
-
Save bmander/734162 to your computer and use it in GitHub Desktop.
display maps color-coded by intersection connectivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
def main(osmdb_name, gdb_name,map_filename): | |
osmdb = sqlite3.connect(osmdb_name) | |
gdb = sqlite3.connect(gdb_name) | |
c = gdb.cursor() | |
c.execute( "select vertex1, count(*) from edges where vertex1 LIKE 'osm%' group by vertex1" ) | |
intersection_counts = dict(list(c)) | |
c.close() | |
c = osmdb.cursor() | |
c.execute("""select min(lon),min(lat),max(lon),max(lat) from nodes""") | |
ll,bb,rr,tt = list(c)[0] | |
from prender import processing | |
mr = processing.MapRenderer() | |
mr.start(ll,bb,rr,tt,3000) #left,bottom,right,top,width | |
mr.background(255,255,255) | |
mr.strokeWeight(0.001) | |
mr.smooth() | |
c.execute( "select id,lat,lon from nodes where endnode_refs>1" ) | |
for id,lat,lon in c: | |
if "osm-%s"%id in intersection_counts: | |
count=intersection_counts["osm-%s"%id] | |
if(count==3): | |
mr.stroke(64,64,64) | |
elif(count==4): | |
mr.stroke(255,0,0) | |
elif(count>2): | |
mr.stroke(128,128,128) | |
else: | |
continue | |
mr.point( lon,lat ) | |
print id,lat,lon,intersection_counts["osm-%s"%id] | |
c.close() | |
mr.saveLocal(map_filename) | |
mr.stop() | |
if __name__=='__main__': | |
main('/home/brandon/Desktop/pugetsound/pugetsound.osmdb','/home/brandon/Desktop/pugetsound/pugetsound.gdb',"/home/brandon/Desktop/pugetsound/map.png") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment