Skip to content

Instantly share code, notes, and snippets.

View nbumbarger's full-sized avatar

Nick Bumbarger nbumbarger

View GitHub Profile
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background: #222;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//d3js.org/d3.geo.projection.v0.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Convex Hull</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Original</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>100m buffer</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@nbumbarger
nbumbarger / index.html
Created November 12, 2015 17:23
Gara Djebilet PCA (Mapbox slider, image processing example)
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Gara Djebilet PCA</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@nbumbarger
nbumbarger / index.html
Last active November 12, 2015 17:20
Gara Djebilet Band Ratio (Mapbox slider, image processing example)
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Gara Djebilet Band Ratio</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v2.2.3/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://d3js.org/d3.v3.js"></script>
<script src="http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>
@nbumbarger
nbumbarger / gist:a152517c2c7a9680f026
Last active August 29, 2015 14:22
Convert addresses to KML (geocoding API)
# From: http://www.nickbumbarger.com/2015/05/31/spatial_data_production.html
require "HTTParty"
def geocode(address)
results = HTTParty.get("https://maps.googleapis.com/maps/api/geocode/json?address="+address)["results"]
location = results.first["geometry"]["location"]
end
def placemark_template(name, lat, lng)
placemark = "<Placemark>\n<name>#{name}</name>\n<Point>\n<coordinates>\n#{lng},#{lat},0\n</coordinates>\n</Point>\n</Placemark>\n"
end
#Start with the address data
@nbumbarger
nbumbarger / gist:0a9615cca929e0a31029
Created June 1, 2015 12:39
Geocode a list of addresses
# From: http://www.nickbumbarger.com/2015/05/31/spatial_data_production.html
require "HTTParty"
def geocode(address)
results = HTTParty.get("https://maps.googleapis.com/maps/api/geocode/json?address="+address)["results"]
location = results.first["geometry"]["location"]
end
#Start with the original address data
data = "GA Washington DC\t1133 15th Street NW, 8th Floor Washington, DC 20005\nGA New York\t902 Broadway, 4th Floor New York, NY 10010\nGA Chicago\t444 N Wabash Ave, 5th Floor Chicago, IL 60611\n"
#Split into names and addresses, and send the address to the geocoder
#Reform the original text with coordinates in the place of addresses
@nbumbarger
nbumbarger / gist:53ef6f4d7576a2f4efb1
Created June 1, 2015 12:35
Convert a list of coordinates to KML
# From: http://www.nickbumbarger.com/2015/05/31/spatial_data_production.html
def placemark_template(name, lat, lng)
placemark = "<Placemark>\n<name>#{name}</name>\n<Point>\n<coordinates>\n#{lng},#{lat},0\n</coordinates>\n</Point>\n</Placemark>\n"
end
#Start with the raw text
data = "GA Washington DC\t38.90485\t-77.03394\nGA New York\t40.73930\t-73.98942\nGA Chicago\t41.89061\t-87.62688"
#Define an empty body and split the text into attributes
#Insert attributes into the placemark template and append result to the body
body = String.new
raw_data.split("\n").each do |line|