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 / xml2json.js
Created September 17, 2014 18:28
convert xml to json nodejs command line utility
#!/usr/bin/env node
var parser = require('xml2json');
var fs = require('fs');
function onFile(err, data) {
if (err) {
console.log('Uh oh: ' + err);
return;
}
var json = parser.toJson(data);
@hrwgc
hrwgc / mercantile-tiles-from-geojson.sh
Last active August 29, 2015 14:11
mercantile find web mercator tiles for a given zoom level based on geojson feature collection
#!/bin/bash
function to_tiles(){
geojson=$1;
zoom=$2;
jq -c .features[] < "$geojson" | mercantile tiles $zoom | sort | uniq
}
@hrwgc
hrwgc / index.html
Created July 13, 2012 02:49 — forked from bsudekum/Interact.txt
Files for GitHub tiles
<DOCTYPE html>
<html>
<head>
<title>Stop and Frisk</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if lte IE 8]><link rel="stylesheet" href="js/ext/wax/ext/leaflet.ie.css" /><![endif]-->
<script src="js/ext/wax/ext/leaflet.js"></script>
<script src='js/ext/wax/dist/wax.leaf.min.js' type='text/javascript'></script>
<link rel="stylesheet" href="js/ext/wax/ext/leaflet.css" />
@hrwgc
hrwgc / hirise.sh
Created October 20, 2012 15:23
Scrape University of Arizona HiRise FTP archive for metadata files
#!/bin/bash
## Usage: ./hirise.sh
## This is a self-contained script to scrape the University of Arizona's HiRise imaging experiment FTP archive. it generates a single file (FILES.txt) containing urls for each Mars image in the archive. This makes it easier to programatically access the metadata .LBL files and ultimately, the source images (.jp2).
declare -a DIRECTORIES=('ORB_011200_011299' 'ORB_011300_011399' 'ORB_011400_011499' 'ORB_011500_011599' 'ORB_011600_011699' 'ORB_011700_011799' 'ORB_011800_011899' 'ORB_011900_011999' 'ORB_012000_012099' 'ORB_012100_012199' 'ORB_012200_012299' 'ORB_012300_012399' 'ORB_012400_012499' 'ORB_012500_012599' 'ORB_012600_012699' 'ORB_012700_012799' 'ORB_012800_012899' 'ORB_012900_012999' 'ORB_013000_013099' 'ORB_013100_013199' 'ORB_013200_013299' 'ORB_013300_013399' 'ORB_013400_013499' 'ORB_013500_013599' 'ORB_013600_013699' 'ORB_013700_013799' 'ORB_013800_013899' 'ORB_013900_013999' 'ORB_014000_014099' 'ORB_014100_014199' 'ORB_014200_014299' 'ORB_014300_014399' 'ORB_014
@hrwgc
hrwgc / gdal_outlines.sh
Created November 2, 2012 01:11
gdal trace raster outlines
## run in a directory with many raster images containing nodata values that make their gdalinfo extents unreliable. output is a csv containing filename and data-containing extents, to be imported into postgis, sqlite, etc for running spatial queries.
## usage:
echo "file;GEOMETRY" > index.csv
declare -a FILES=$(ls -1 *tif);
for FILE in ${FILES[@]}; do
FILE=${FILE%.tif}
echo "$FILE.tif;" > $FILE.txt
gdal_trace_outline $FILE.tif -ndv '0 0' -out-cs en -wkt-out $FILE.wkt
cat $FILE.wkt >> $FILE.txt
@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
}, {

before

30 meter resolution EO1-ALI Satellite Image

After

@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 / 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 / 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.