Created
November 5, 2013 19:43
-
-
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.
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
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