Skip to content

Instantly share code, notes, and snippets.

@jgomezdans
jgomezdans / dn_2_rad.py
Last active September 13, 2021 12:56
Landsat DN to radiance script using GDAL and Numpy.
#!/usr/bin/env python
"""
SYNOPSIS
dn_2_rad.py [-h,--help] [-v,--verbose] [-i,--input] [-o,--output]
DESCRIPTION
This program is used to extract the gain parameters and to convert
@celoyd
celoyd / ndvi.py
Last active October 4, 2022 11:03
#!/usr/bin/env python
# ndvi.py red.tif nir.tif output-ndvi.tif
# Calculate NDVI (see Wikipedia). Assumes atmospheric correction.
# (Although I use it without all the time for quick experiments.)
import numpy as np
from sys import argv
from osgeo import gdal, gdalconst
@oeon
oeon / landsat_notes.md
Last active April 27, 2017 05:21
notes from processing Harmony Landsat post

##This workflow is only for the pansharpened images

####red-green-blue
gdalbuildvrt -separate -q -srcnodata "0 0 0" -vrtnodata "0 0 0" rgb.vrt LC80430352013339LGN00_B4.tif LC80430352013339LGN00_B3.tif LC80430352013339LGN00_B2.tif

####NIR, SWIR, and visible red
gdalbuildvrt -separate -q -srcnodata "0 0 0" -vrtnodata "0 0 0" false.vrt LC80430352013339LGN00_B5.tif LC80430352013339LGN00_B6.tif LC80430352013339LGN00_B4.tif

####color infrared
gdalbuildvrt -separate -q -srcnodata "0 0 0" -vrtnodata "0 0 0" cir.vrt LC80430352013339LGN00_B5.tif LC80430352013339LGN00_B3.tif LC80430352013339LGN00_B4.tif

@dwtkns
dwtkns / l8get
Last active October 1, 2017 20:19
A shell function to quickly grab the data for a given Landsat 8 tile ID from Google's servers
# This is a shell function to quickly grab the data for a given Landsat 8 tile ID from Google's servers
# For example:
# l8get LC81690352014169LGN00
# The echo at the end is to remind myself of the syntax for extracting bands 8, 4, 3, and 2. (Pansharp, Red, Green, Blue)
# On OSX this would go into your ~/.bash_profile file.
# Requires gsutil from https://developers.google.com/storage/docs/gsutil_install
# Most useful in conjunction with USGS' Earth Explorer: http://earthexplorer.usgs.gov/
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@dwtkns
dwtkns / l8_pansharp.sh
Created July 30, 2014 18:26
l8_pansharp
# These are shell functions to quickly create pansharpened RGB images ready for color correction
# from a set of raw Landsat 8 TIF files in a given directory.
# For example:
# l8_pansharp LC81690352014169LGN00
# Creates:
# LC81690352014169LGN00_rgb_pansharp.tif
# l8_rush_pansharp downloads a L8 tile from Google Storage (if they have it), extracts the relevant bands, then creates the pansharpened output.
@briantjacobs
briantjacobs / l8get
Last active August 29, 2015 14:06 — forked from dwtkns/l8get
# This is a shell function to quickly grab the data for a given Landsat 8 tile ID from Google's servers
# For example:
# l8get LC81690352014169LGN00
# The echo at the end is to remind myself of the syntax for extracting bands 8, 4, 3, and 2. (Pansharp, Red, Green, Blue)
# On OSX this would go into your ~/.bash_profile file.
# Requires gsutil from https://developers.google.com/storage/docs/gsutil_install
# Most useful in conjunction with USGS' Earth Explorer: http://earthexplorer.usgs.gov/
@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
@albert-decatur
albert-decatur / See-scene.sh
Last active August 29, 2015 14:19
see landsat-api scene extents on geojson.io
#!/bin/bash
# see Development Seed landsat-api scene extent on geojson.io
# example use: $0 LC81660362014196LGN00
scene=$1
# get scene metadata from devseed landsat-api
curl -s "https://api.developmentseed.org/landsat?search=${scene}" |\
# get corner coords
jq '.results[]|[.lowerLeftCornerLongitude,.lowerLeftCornerLatitude,"",.lowerRightCornerLongitude,.lowerRightCornerLatitude,"",.upperRightCornerLongitude,.upperRightCornerLatitude,"",.upperLeftCornerLongitude,.upperLeftCornerLatitude,"",.lowerLeftCornerLongitude,.lowerLeftCornerLatitude]|@csv' |\
@kgjenkins
kgjenkins / carson-projection.png
Last active July 18, 2016 21:48
Carson projection in CartoDB PostGIS
carson-projection.png