Skip to content

Instantly share code, notes, and snippets.

View hrwgc's full-sized avatar

Chris Herwig hrwgc

  • Google
  • San Francisco
View GitHub Profile
@hrwgc
hrwgc / smithsonian_folkways.geojson
Created June 1, 2013 16:58
smithsonian folkways record collection
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hrwgc
hrwgc / postgresql_quantiles.md
Last active May 31, 2018 13:36
Calculate quantile distributions for PostgreSQL column
SELECT
ntile,
CAST(avg(length) AS INTEGER) AS avgAmount,
CAST(max(length) AS INTEGER)  AS maxAmount,
CAST(min(length) AS INTEGER)  AS minAmount 
FROM (SELECT length, ntile(6) OVER (ORDER BY length) AS ntile FROM countries) x
GROUP BY ntile
ORDER BY ntile;
@hrwgc
hrwgc / noaa_viirs_fire.py
Last active December 12, 2015 07:28
Scraper for NOAA VIIRS Combustion Source CSVs
import urllib2, urllib
import re, os
import sqlite3
import uuid
import contextlib
from bs4 import *
import csv
import unicodedata
@hrwgc
hrwgc / nasa_iotd.py
Last active December 12, 2015 02:38
Create SQLite archive of NASA image of the day blog #Python #BeautifulSoup #SQLite
import scraperwiki
import urllib2, urllib
import re, os
import sqlite3
import uuid
from bs4 import *
import lxml
import unicodedata
from time import sleep
@hrwgc
hrwgc / README.md
Last active September 4, 2023 11:15
VIIRS Nighttime Lights 2012 processing
@hrwgc
hrwgc / mapbox_learn.md
Last active September 5, 2016 15:24
Resources for those just starting with Mapbox, TileMill, and Quantum GIS

before

30 meter resolution EO1-ALI Satellite Image

After

@hrwgc
hrwgc / custom_interactivity.js
Created January 20, 2013 19:18
custom interactivity with data contained in mbtiles rather than pre-formatted tooltips
mapbox.load('herwig.map-siz5m7we', function(o) {
var map = mapbox.map('map');
map.addLayer(o.layer);
map.zoom(4).center({
lat: -28.613,
lon: 144.14
}).setPanLimits([{
lat: -85.0511,
lon: -180
}, {
@hrwgc
hrwgc / README.md
Last active May 3, 2020 01:12
download all of your gists from gist.github.com

gist list

A command line script to retrieve json for all of your gists.

usage:

github.sh [username] [password] [total number of gists] [oath or user:password]
@hrwgc
hrwgc / wkt_to_proj4.py
Created January 2, 2013 16:37
WKT to Proj4 string GDAL python
from osgeo import osr
srs = osr.SpatialReference()
wkt_text = 'PROJCS["Transverse Mercator",GEOGCS["GCS_Everest_1830",DATUM["D_Everest_1830",SPHEROID["Everest_1830",6377299.36,300.8017]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500295.0],PARAMETER["False_Northing",-2000090.0],PARAMETER["Central_Meridian",90.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]'
srs.importFromWkt(wkt_text)
srs.ExportToProj4()