Skip to content

Instantly share code, notes, and snippets.

View danhammer's full-sized avatar

Dan danhammer

View GitHub Profile
@danhammer
danhammer / convert.py
Created March 22, 2014 03:04
Grab information on forest cover loss for the supplied shapefile
import os
import requests
import json
import pandas as pd
# Go from JSON to a measurement of UMD deforestation by year. If you
# have a shapefile, you will have to convert and simplify the
# polygons, preserving topology. The Earth Engine API does not
# support long, long requests. You can convert the shapefile using
# OGR within the data subdirectory:
@danhammer
danhammer / grab_ngos.py
Created April 8, 2014 22:01
Grab the NGO coordinates from bettermap.org
import requests
import pandas
from BeautifulSoup import BeautifulSoup
def _grab_data():
url = 'http://www.bettermap.org/json'
x = requests.get(url)
return x.json()['features']
def _process_entry(entry):
from bs4 import BeautifulSoup
import json
import pandas as pd
# Process information on Caltrans projects. Convert this file to
# GeoJSON:
# wget https://dot.ca.gov/hq/construc/cons.kml
# ogr2ogr -f GeoJSON cons.json cons.kml
# 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.