Created
September 13, 2019 19:14
-
-
Save kristopolous/40943f2babfcaa6fdb48953192fb352b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/python | |
import sys | |
import png | |
from pprint import pprint | |
cx = 0 | |
width = 4000 | |
height = 4000 | |
image = [ [ 0 for y in range ( width ) ] for x in range( height ) ] | |
bitdepth = 2 | |
maxval = pow(2, bitdepth) | |
delta_lng = .8 | |
delta_lat = delta_lng | |
lng_low = -118.8 | |
lng_high = lng_low + delta_lng | |
lat_low = 33.70 | |
lat_high = lat_low + delta_lat | |
mult_lng = 360 / delta_lng * .999 | |
mult_lat = 180 / delta_lat * .999 | |
for line in sys.stdin: | |
lat, lng = line.split(',') | |
lat = float(lat) | |
lng = float(lng) | |
cx += 1 | |
if(lng > lng_low and lng < lng_high and lat > lat_low and lat < lat_high): | |
x = int(round( (mult_lng * width/360.0) * (lng - lng_low))) | |
y = int(round( (mult_lat * height/180.0) * (lat - lat_low))) | |
try: | |
if image[y][x] < maxval: | |
image[y][x] += 1 | |
except Exception as ex: | |
print(x, y) | |
raise ex | |
f = sys.stdout | |
w = png.Writer(width, height, greyscale=True, bitdepth=bitdepth) | |
w.write(f, reversed(image)) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment