Skip to content

Instantly share code, notes, and snippets.

View danhammer's full-sized avatar

Dan danhammer

View GitHub Profile
@danhammer
danhammer / gist:109a3789bc811d29abab
Created September 25, 2014 17:39
scrape spaceapps
from bs4 import BeautifulSoup
import requests
import urllib
import pandas
import json
import itertools
import os
BASE = "https://2014.spaceappschallenge.org/awards/#globalnom"
GOOGLE_GEOCODE_URL = 'https://maps.googleapis.com/maps/api/geocode/json'
@danhammer
danhammer / gist:7d844482de9a42aba185
Last active August 29, 2015 14:15
quick script to show earth imagery in python
import requests
from StringIO import StringIO
from pprint import pprint
from PIL import Image
from numpy import array
base = "https://api.data.gov/nasa/planetary/earth"
payload = {
"lon": -122.066133,
import requests
import urllib
BASE = "http://beta.gfw-apis.appspot.com/forest-change/forma-alerts"
period = "2008-01-01,2012-09-24"
sample_area = {
"geometry": {
"type": "Polygon",
"coordinates": [
@danhammer
danhammer / map.geojson
Created April 15, 2015 15:18
kalimantan sample region
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@danhammer
danhammer / vegetation_grab.py
Last active August 29, 2015 14:25
Demonstration of vegetation score extraction
# Sample code to demonstrate the vegetation extraction from satellite imagery.
# The example region is a small plot in the central valley:
# https://gist.github.com/danhammer/47590518ece27c2ef0ab
# Specifically, this reports the mean and standard deviation EVI score for all
# 30m pixels within the supplied polygon. To install the requests package on a
# Mac, type `sudo pip install requests` or visit this page for more comprehensive
# install instructions:
# Sample code to identify buildings withing a supplied bounding box.
import requests
def grabber(bbox, residential=True):
BASE = "http://wolak.enviro-service.appspot.com/buildings"
payload = bbox
payload['residential'] = residential
res = requests.get(BASE, params=payload).json()
return res
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@danhammer
danhammer / jobs.py
Last active November 23, 2015 17:25
A rough and ready script to scrape and analyze positions posted on higheredjobs.com
# Clean jobs data
import requests
import pandas as pd
from bs4 import BeautifulSoup
def collect_links(category_idx=231):
# Collect the links to individual jobs given by the supplied category index
LIST_BASE = "https://www.higheredjobs.com/faculty/search.cfm"
@danhammer
danhammer / census_getter.py
Last active January 31, 2016 19:04
Converts a street address to a census tract number, based on current Census benchmark and vintage
import requests
import urllib
def census_tract(street_address, city, state):
"""
Accepts an address -- split into street number, city, and state -- and
returns the census tract number as a string.
Example: