This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// grab background: StreetView or uploaded | |
// 600 x 435 pixels | |
var bg = $('canvas')[1].parentNode.style.backgroundImage.substring(4); | |
bg = bg.substring(0, bg.length - 1); | |
var bgimage = new Image(); | |
bgimage.onload = function(){ | |
// grab image from foreground canvas | |
// 600 x 435 pixels to avoid menus | |
var uppercanv = $('canvas')[1].getContext('2d').getImageData(0, 0, 600, 435); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OSM Points and Streets | |
# Build from nodes and ways | |
# For each way, add them to Streets | |
## Flag each node with the Street's ID | |
## If Street shares a node with a previous Street, build a connectsto relation between the two | |
# Optional firstToAdd parameter lets you pick up networking where you left off | |
firstToAdd = None | |
# firstToAdd = "featherdr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HouseNet.py | |
# upload housing cases into the graph database | |
import urllib, urllib2 | |
cases = open('PROP1Cleanest.csv', 'r') | |
streetids = { } | |
skipto = "1903 houstonave"; | |
skipcount = 0 | |
for line in cases: | |
# add cases to neo4j |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HouseNet.py | |
# upload housing cases into the graph database | |
import urllib, urllib2 | |
cases = open('cases-predicted.csv', 'r') | |
caseout = open('PROP1NetworkedResults.csv', 'w') | |
streetids = { } | |
streetmatches = { } | |
skipto = "1903 houstonave"; | |
skipcount = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NetworkStats.py | |
# compare demolition count (on network level) to other cases (on network level) | |
import urllib, urllib2 | |
skipcount = 0 | |
countable = 'class="point"' | |
neighbortotals = [] | |
demototals = [] | |
ratiototals = [] | |
streetid = skipcount | |
countsbystreetid = { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 < 2 years) | |
# "Demolished", 20030101, Demolished |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for GridMapper and GridMapAuth: | |
# Combine a custom grid and Census 2010 blocks shapefile in QGIS | |
# Run script | |
# Output JSON object with Census blocks overlapped by each grid | |
def squareName(i, j): | |
letter = chr(65+i) | |
return letter + str(j + 1) | |
# get the active layer (Census blocks) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Quick QGIS scripts to extract housing and population data from Census blocks | |
# get the active layer (Census blocks) | |
from PyQt4 import QtCore | |
activeLayer = qgis.utils.iface.activeLayer() | |
provider = activeLayer.dataProvider() | |
allAttrs = provider.attributeIndexes() | |
provider.select(allAttrs) | |
feat = QgsFeature() | |
while provider.nextFeature(feat): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Put your GeoJSON at the beginning | |
// Here are some more countries and each US state: https://github.com/johan/world.geo.json/tree/master/countries | |
// scroll to the bottom to write your own program, add images by latitude and longitude, and more | |
// Questions? Tweet to @mapmeld | |
var geojson = {"type":"FeatureCollection","features":[ | |
{"type":"Feature","properties":{"name":"United States of America"},"geometry":{"type":"MultiPolygon","coordinates":[[[[-94.81758,49.38905],[-94.64,48.84],[-94.32914,48.67074],[-93.63087,48.60926],[-92.61,48.45],[-91.64,48.14],[-90.83,48.27],[-89.6,48.01],[-89.272917,48.019808],[-88.378114,48.302918],[-87.439793,47.94],[-86.461991,47.553338],[-85.652363,47.220219],[-84.87608,46.900083],[-84.779238,46.637102],[-84.543749,46.538684],[-84.6049,46.4396],[-84.3367,46.40877],[-84.14212,46.512226],[-84.091851,46.275419],[-83.890765,46.116927],[-83.616131,46.116927],[-83.469551,45.994686],[-83.592851,45.816894],[-82.550925,45.347517],[-82.337763,44.44],[-82.137642,43.571088],[-82.43,42.98 |