Skip to content

Instantly share code, notes, and snippets.

View mapmeld's full-sized avatar

Nick Doiron mapmeld

  • Chicago, IL
View GitHub Profile
@mapmeld
mapmeld / housecasedata.py
Created July 1, 2012 13:57
HouseCaseData
# stats and scraper for Macon Code Enforcement Housing Data
import datetime
prop = open('PROP1.csv', 'r')
thisyr = open('cases-2012.csv', 'w')
startdate = None
enddate = None
casespan = None
@mapmeld
mapmeld / PredictPrep.py
Created July 11, 2012 00:50
PredictPrep
# Predict Cases
# Prepare housing cases CSV for Google Prediction API
# Now associates a case with where it is in three more years, not the ultimate result
# for example
# "Some", 19960909, Cut and Cleared
# "None", 19980101, Cut and Cleared
# "None", 19980202, No Violations (not predicted by previous because there were no violations)
# "Demolished", 20020808, Repaired (prediction should be demolished because demo comes in < 3 years)
# "Demolished", 20030101, Demolished
@mapmeld
mapmeld / maconcraft.rb
Created July 12, 2012 18:59
Soothsayer and Macon Houses
require 'Soothsayer'
Soothsayer.config do |c|
# get keys from http://rubydoc.info/gems/soothsayer/0.0.3/frames
c.client_id = ""
c.client_secret = ""
c.access_token = ""
c.refresh_token = ""
end
@mapmeld
mapmeld / geomatch.py
Created July 18, 2012 06:42
Geo-matching for Prediction CSVs
# Go through a CSV file of addresses
# Find each address in a KML file
# Add the coordinates to the CSV file if a match is found
# Add Geostuff to addresses
cases = open('PROP1Cleanest.csv', 'r')
geocases = open('allcasesplusgeo.csv', 'w')
lastgeo = [ ]
geobyaddress = { }
@mapmeld
mapmeld / GPS_bustimetabler.py
Created July 25, 2012 22:45
GPS-BusTimeTabler
# Bus TimeTabler from My Tracks GPS App
# Imports CSV of Bus GPS points and KML of Bus Stops along a route.
# Helps create a complete timetable by recording when selected vehicles on this route approach the stop
import datetime
# import a day's worth of bus tracks
bustrackfile = open('Bus13.csv', 'r')
bustrack = [ ]
for line in bustrackfile:
@mapmeld
mapmeld / CensusAPI.txt
Created August 2, 2012 23:01
Using the Census API
NOTE: This how-to was written for the Census API at http://thedataweb.rm.census.gov/ -- it has since been moved to http://api.census.gov/
Mike Stucka, our contact at the Macon Telegraph, sent us a link to the Census's official API which is launching next month. You can skip ahead to the site - http://www.census.gov/developers/ - and get an API key, but also read my notes after using this yesterday:
1) The datasets
--- The 2010 Census Summary comes from everyone filling out census forms, and you can get stats at state level down to a super-detailed block level. Info from this includes population, age, gender, race, home ownership, members of a household, and various combinations of that. Full list: http://www.census.gov/developers/data/sf1.xml
--- The 2006-2010 American Community Survey is a longer form given to fewer households over 5 years (so its numbers are incompatible with the 2010 Census). You can get stats down only to the block group level. In addition to the standard census stats, you get: educa
@mapmeld
mapmeld / olpc-nfc-io.py
Created August 4, 2012 04:54
OLPC-NFC-IO
# Reader.py
# RFID / NFC Card Reader
# For adding names to each card and reading them out loud
import sys, os
# test if pyserial library is installed
try:
import serial
except:
@mapmeld
mapmeld / ServerMakesMotorRun.js
Created August 5, 2012 02:40
Server-Makes-Motor-Run
// CfA Liberty Bell Project
var http = require('http');
var five = require("johnny-five");
var board = new five.Board();
board.on("ready", function() {
@mapmeld
mapmeld / ColumnPopulator.py
Created August 8, 2012 23:43
Column Populator Script for QGIS
# Column Populator Script for QGIS
# We have a lot of RouteNames in one column, and we want that to translate into other columns
# For example, RouteName=Ocmulgee should set Route5=1 and leave all others NULL
from PyQt4 import QtCore
activeLayer = qgis.utils.iface.activeLayer()
layerData = activeLayer.dataProvider()
columns = layerData.fields()
@mapmeld
mapmeld / multicolumnpopulator.py
Created August 9, 2012 00:40
Multi-Column Populator for QGIS
# Multi-Column Populator for QGIS
# Go through a huge String of bus stops and the buses which stop there
# Set Route1 = 1 wherever that route stops
# Set Route2 = 1 wherever that route stops
# and so on
from PyQt4 import QtCore
# populate dictionary of points based on the OBJECTID attribute used to identify the bus stop
pts_by_id = { }