Skip to content

Instantly share code, notes, and snippets.

View celoyd's full-sized avatar

Charlie Loyd celoyd

View GitHub Profile

I've rendered out two map layers with pre-typhoon Landsat 8 imagery. This is very low resolution (15 m) but may help fill in major highways and rivers for areas that still lack better coverage. They include clouds because I found that splicing them together can introduce seam artifacts that could be mistaken for roads.

The layer templates are:

@celoyd
celoyd / corr.py
Last active December 25, 2015 19:59
World’s simplest band correlation visualizer
#!/usr/bin/env python
# Simple script to scatterplot one band's values over another's into a third image.
# Usagi Yojimbo: corr.py band_1.tif band_2.tif 2_v_3.tif
# This is for quick testing; don't use it in place of proper statistics.
# It may overflow, will fail if the inputs are not identically formatted, etc.
# You may have to scale up the output (perhaps by increasing gamma).
import Image
from sys import argv
#!/usr/bin/env python
from sys import argv, exit
import Image
import time
from numpy import *
avgtype = float32
avg = array([])
if tiff_h is None:
include_tiff_h = os.path.join(os.path.split(lib)[0], '..', 'include', 'tiff.h')
if not os.path.isfile(include_tiff_h):
# fix me for windows:
include_tiff_h = os.path.join('/usr','include','tiff.h')
if not os.path.isfile(include_tiff_h):
raise ValueError('Failed to find TIFF header file (may be need to run: sudo apt-get install libtiff4-dev)')
# Read TIFFTAG_* constants for the header file:
f = open (include_tiff_h, 'r')
l = []
#!/usr/bin/env python
import psycopg2 as pg
import Image
from sys import argv
conn = pg.connect(database='tweets', user='char', host='localhost')
cur = conn.cursor()
pxper = 16
char@mako: identify -list format 0 ~/Desktop
Format Module Mode Description
-------------------------------------------------------------------------------
3FR DNG r-- Hasselblad CFV/H3D39II
A* RAW rw+ Raw alpha samples
AAI* AAI rw+ AAI Dune image
AI PDF rw- Adobe Illustrator CS2
ART* ART rw- PFS: 1st Publisher Clip Art
ARW DNG r-- Sony Alpha Raw Image Format
AVI MPEG r-- Microsoft Audio/Visual Interleaved
@celoyd
celoyd / t.py
Last active October 2, 2018 23:36
A simple, mostly-not-mine Twitter stream consumer and s3 bucketer
#!/usr/bin/env python
'''
This code is adapted from the consensus best practice python Twitter feed
consumer that's been floating around for a while now on StackOverflow etc.
My only addition to speak of is TenminWriter. (A "tenmin" is ten minutes
worth of stream. It's just a convenient chunk; you might want to make it
shorter or longer.)
THERE ARE BUGS HERE. THIS IS BARELY TESTED. DO NOT TRUST IT.
# Quickie processing for LC81770782013190LGN00
# Cf. http://mapbox.com/blog/processing-landsat-8/
convert -combine *_B{4,3,2}.TIF rgb.tif
convert -resize 200% rgb.tif rgb-big.tif
convert -compose Colorize *_B8.TIF rgb-big.tif -composite pan.tif
convert -channel B -gamma 0.95 -channel RGB -sigmoidal-contrast 60x13% pan.tif ready.tif
convert -crop 3000x2000+8000+6000 ready.tif crater.jpeg
convert -crop 3000x2000+2000+6000 ready.tif cliff.jpeg