Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am celoyd on github.
* I am vruba (https://keybase.io/vruba) on keybase.
* I have a public key whose fingerprint is ACAD 5D75 5F30 8F1B 1504 B132 EB31 5C66 7D17 6C9D
To claim this, I am signing this object:
# dirty l8 scaling in python
# Charlie Loyd, fall 2013
# note use of arbitrary 160000 scale factor in L48
from math import sin
from sys import argv, exit
from osgeo import gdal, gdalconst
import os.path
from numpy import *
@celoyd
celoyd / simple-l8-pan-draft.py
Last active August 29, 2015 14:02
do not use this
# PRE-ALPHA!
import asyncio
import rasterio as rio
import numpy as np
from rasterio.warp import reproject, RESAMPLING
'''
./pan.py print/LC81100362014076LGN00/*B{4,3,2,8}.TIF out.tif
# To help with https://xkcd.com/936/
randword () {
dict=/usr/share/dict/words
r=$((($RANDOM * $RANDOM) % `wc -l $dict | awk '{print $1}'`))
head -n $r $dict | tail -n 1
}
# Beta-quality Landsat 8-oriented windowed pansharpener by Charlie Loyd
# python3 panchunk.py $SCENE/*B{4,3,2,8}.TIF ${SCENE}-pansharp.tif
# Then you may want something like this to brighten it up:
# convert -channel B -gamma 0.96 -channel RGB -sigmoidal-contrast 40,14% ${SCENE}-pansharp.tif ${SCENE}-pretty.tif
# But that will strip geo tags.
import asyncio
import rasterio as rio
#!/usr/bin/env python
# not properly tested
from sys import argv
from PIL import Image
import numpy as np
A, B = (
np.asarray(Image.open(x)).astype(np.float32)
#!/usr/bin/env python
import sys
import os
import numpy
from osgeo import gdal, gdal_array
TAIL_TRIM = 0.01
-- copy eight from '/Users/ch/Desktop/meta/LANDSAT_8.csv' delimiter ',' CSV header;
create type sensor_t as enum ('OLI_TIRS', 'OLI', 'TIRS');
create type daynight_t as enum ('DAY', 'NIGHT');
create type datatype_t as enum ('L1GT', 'L1T', 'PR');
create type nadir_t as enum ('NADIR', 'OFFNADIR');
create table eight (
sceneID text primary key,
sensor sensor_t,
#!/usr/bin/env python
import numpy as np
import sys
import rasterio as rio
chip = open(sys.argv[1]).read(4096)
chip = np.fromstring(chip, dtype='uint8')
chip = chip.reshape(64, 64)
#!/usr/bin/env python
import rasterio as rio
import numpy as np
import sys
with rio.open(sys.argv[1], 'r') as src:
meta = src.meta
cplx = src.read(1)