Skip to content

Instantly share code, notes, and snippets.

View danhammer's full-sized avatar

Dan danhammer

View GitHub Profile
# Accepts a results dictionary and writes an short analysis based on
# the stored results. Example:
# test_res_dict = {
# 'address' : '1460 Golden Gate Avenue, San Francisco, CA',
# 'sold_date' : '2008-04-21',
# # baseline level of vegetation or some other sort of indicator of
# # the property.
# 'pre_ndvi' : 100,
def landsatID(alert_date, coords, offset_days=30):
"""get the ID of the Landsat 8 image that is closest to the
supplied alert date within the supplied GEE-formatted polygon
"""
d = datetime.datetime.strptime(alert_date, '%Y-%m-%d')
begin_date = d - datetime.timedelta(days=offset_days)
poly = ee.Feature.Polygon(coords)
@danhammer
danhammer / gist:8fdb1744db2e35e682de
Created July 10, 2014 22:13
forma playground code, working
// FORMA, Hammer et al. (2014)
// Objective:
// Alerts of forest disturbance from MODIS imagery
// GEE core assets:
// MOD44B_C4_TREE_2000 (Vegetation Continuous Fields, annual 250m)
// MOD13Q1 (Vegetation indices, 16-day 250m)
// NOAA/PRECL_05D (Precipitation Reconstruction over Land, monthly 0.5 degree)
@danhammer
danhammer / gist:2b7b70b98a6bc693ac7e
Created July 11, 2014 06:22
working forma, draft
// FORMA, Hammer et al. (2014)
// Objective:
// Alerts of forest disturbance from MODIS imagery
// GEE core assets:
// MOD44B_C4_TREE_2000 (Vegetation Continuous Fields, annual 250m)
// MOD13Q1 (Vegetation indices, 16-day 250m)
// NOAA/PRECL_05D (Precipitation Reconstruction over Land, monthly 0.5 degree)
@danhammer
danhammer / normalized_burn_ratio
Created July 14, 2014 19:10
normalized burn ratio
// Normalized Burn Ratio
// Hammer, Kraft, and Steele (Data Lab at WRI)
// GFW-Fires, prototype
// Reference
// Escuin, S., R. Navarro, P. Fernandez. 2008. Fire severity assessment by
// using NBR (Normalized Burn Ratio) and NDVI (Normalized Difference
// Vegetation Index) derived from LANDSAT TM/ETM images. Int. J. Remote
// Sens. 29:1053-1073.
@danhammer
danhammer / normalized_burn_ratio
Created July 14, 2014 19:15
normalized burn ratio
// Normalized Burn Ratio
// Hammer, Kraft, and Steele (Data Lab at WRI)
// GFW-Fires, prototype
// Reference
// Escuin, S., R. Navarro, P. Fernandez. 2008. Fire severity assessment by
// using NBR (Normalized Burn Ratio) and NDVI (Normalized Difference
// Vegetation Index) derived from LANDSAT TM/ETM images. Int. J. Remote
// Sens. 29:1053-1073.
@danhammer
danhammer / normalized_burn_ratio.js
Created July 14, 2014 19:16
normalized burn ratio
// Normalized Burn Ratio
// Hammer, Kraft, and Steele (Data Lab at WRI)
// GFW-Fires, prototype
// Reference
// Escuin, S., R. Navarro, P. Fernandez. 2008. Fire severity assessment by
// using NBR (Normalized Burn Ratio) and NDVI (Normalized Difference
// Vegetation Index) derived from LANDSAT TM/ETM images. Int. J. Remote
// Sens. 29:1053-1073.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import requests
import multiprocessing
from datetime import datetime
ALERT_URL = 'http://forma-cs-validation.elasticbeanstalk.com/api/alerts'
def _screener(x):
try:
not_cached = x['cached'] is not True
import scipy
from scipy import ndimage
import copy
import matplotlib
matplotlib.use('Agg') # Must be before importing matplotlib.pyplot or pylab!
import matplotlib.pyplot as plt
import numpy as np
from spaceknow.horik import tools