Skip to content

Instantly share code, notes, and snippets.

@davepape
Created November 5, 2013 19:43
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 davepape/7324934 to your computer and use it in GitHub Desktop.
Save davepape/7324934 to your computer and use it in GitHub Desktop.
Plots points from the US Census's 2000 gazetteer as a simple equirectangular (latitude/longitude) map.
from pyglet.gl import *
f = open('places2k.txt')
lines = f.readlines()
f.close()
verts = []
for l in lines:
pop = int(l[73:82])
if pop > 0:
lat = float(l[143:153])
lon = float(l[153:164])
verts += [lon, lat]
vlist = pyglet.graphics.vertex_list(len(verts)/2, ('v2f', verts))
window = pyglet.window.Window(1024,512)
@window.event
def on_draw():
glClear(GL_COLOR_BUFFER_BIT)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(-180,180,-90,90,-1,1)
glMatrixMode(GL_MODELVIEW)
glColor3f(1,1,1)
vlist.draw(GL_POINTS)
def update(dt):
pass
pyglet.clock.schedule_interval(update,1/60.0)
pyglet.app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment