Skip to content

Instantly share code, notes, and snippets.

#!/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,
@celoyd
celoyd / ndvi.py
Last active October 20, 2018 19:39
#!/usr/bin/env python
# Very simple rasterio NDVI (or general normalized difference ratio) demo.
# python ndvi.py $landsat_scene/*B{4,5}.TIF ndvi.tif
import rasterio as rio
from sys import argv
import numpy as np
math_type = np.float32 # type for internal calculations
#!/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)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@celoyd
celoyd / l8_toa.py
Last active October 30, 2015 19:04
Simple Landsat 8 TOA, working with MTLs as of mid-2015. NOT CAREFULLY TESTED! Scale factor of 55k.
import click
import rasterio as rio
import os
import numpy as np
import re
from sys import argv, exit
from math import sin, radians
def get_mtl_path(bundle_path):
mtls = [
#!/usr/bin/env python
'''
Makes template filenames for interpolating Himawari-8 data.
Assumes filenames like "2015-11-28T023500.png".
I do this: python betwixt.py day-color | parallel --colsep ' ' convert -average {1} {2} {3}
'''
import os
import sys
@celoyd
celoyd / hi8-anim-howto.md
Last active August 1, 2022 15:37
A way to make Himawari-8 animations

Himawari-8 animation tutorial

Here’s how to make animations like this one. It requires intermediate Unix command-line knowledge, to install some tools and to debug if they don’t work. You’ll need these utilities:

  • curl (or you can translate to wget)
  • convert and montage, part of ImageMagick
  • ffmpeg, plus whatever codecs
  • parallel, for iteration that’s nicer than shell for loops or xargs
  • run everything in zsh for leading 0s in numerical ranges to work