Skip to content

Instantly share code, notes, and snippets.

View drewbo's full-sized avatar

Drew Bollinger drewbo

  • @cloud-gov (work) + personal projects
  • Washington, DC
View GitHub Profile
@drewbo
drewbo / observerdeploymentrd2.md
Last active August 29, 2015 14:02
Observer Deployment Data for the runoff of the 2014 Afghanistan elections

Context

The observer deployment data from the 2014 Afghanistan runoff elections was provided in various forms (excel, word) and saved as xlsx files (so the work is visible) and then csvs with minimal editing. That data is all read into R and joined with the updated polling center data to create the TileMill source data (as a csv).

For manual edits, I added the new name information into rosetta_fix.csv and the new name/spatial information (calculated from iec_runoff_polling_centers_en_jun2014-geojson_cl.csv") to district_centroid.csv.

All the extra lat/long calculations were saved as extracentroidcalc.xlsx.

FEFA

Mapping the Streets of Ireland With R and ggplot2

Earlier today an interesting article about plotting the streets of france appeared in my feed. What Simon does in his blog post is essentially read OSM street-lines-data for France and displays it in what I find to be a rather traditional and elegant way.

The first thing I immediately though of was: "I'd love to see this for Ireland". As an OSX user, it took a few tricks to get the article replicated for Ireland therefore I've decided to share my notes.

Should you wish to replicate this for your country, here are some notes I've taken.

Get The Data

<!DOCTYPE html>
<meta charset="utf-8">
Hello, world!
@drewbo
drewbo / resize.md
Created July 14, 2014 20:31
Resizing D3 SVG

How to create D3 visualizations that resize and scale well

When creating the SVG, add this bit of D3:

.attr("id","chart")
.attr("viewBox","0 0 960 500")
.attr("perserveAspectRatio","xMinYMid")

Then later in the code, add this bit of jQuery:

@drewbo
drewbo / index.html
Last active August 29, 2015 14:05
A demonstration of appending data to DOM elements based on pre-existing ids
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.circle {
fill: steelblue;
}
</style>
<div class="d3" id="foo"></div>
@drewbo
drewbo / ZeroPad.js
Created August 22, 2014 15:21 — forked from mihi-tr/ZeroPad.js
// Zero Pad a number in Javascript
// Takes e.g. zp(42,5) -> "00042"
var zp = function(n,c) {
var s = String(n);
if (s.length< c) { return zp("0" + n,c) }
else { return s } };
(defn zp "Zero Pad numbers - takes a number and the length to pad to as arguments"
[n c]
(loop [s (str n)]
(if (< (.length s) c)
(recur (str "0" s))
s)))
@drewbo
drewbo / README.md
Created September 16, 2014 21:34
An aRanger arrangment.

An arrangement of items made through aRanger.

@drewbo
drewbo / _.md
Created September 17, 2014 18:33
cartogram-test