This file contains hidden or 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
| # Geoless.py | |
| # Look through cases on housing database without a latitude or longitude | |
| # Improve format of address, then assign a location from geocoder.us | |
| import urllib2, json, re, couchdb | |
| # load cases through JSON | |
| geoless = urllib2.urlopen('http://nickd.iriscouch.com:5984/cases/_design/geoless/_view/geoless').read() | |
| readresponse = json.loads(geoless) | |
| cases = readresponse['rows'] |
This file contains hidden or 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
| # load surveys without an address from KML and into CouchDB | |
| # gets geolocation with geocoder.us | |
| import urllib | |
| import urllib2 | |
| import re | |
| import couchdb # pip install couchdb | |
| server = couchdb.client.Server(url="http://nickd.iriscouch.com:5984") |
This file contains hidden or 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
| # CaseAnim.py | |
| # Takes in code enforcement cases with locations | |
| # Also takes in a target neighborhood (College Hill) | |
| # Outputs number of ongoing cases in each month | |
| geocases = open('allcasesplusgeo.csv', 'r') | |
| # College Hill boundary | |
| collegehill = """-83.656990,32.825790,0.000000 | |
| -83.654442,32.825764,0.000000 |
This file contains hidden or 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
| # CasesToTimeline.py | |
| # prepare GeoJSON file for MapBox timeline map example | |
| geocases = open('allcasesplusgeo.csv', 'r') | |
| json = open('output.json', 'w') | |
| # College Hill boundary | |
| collegehill = """-83.656990,32.825790,0.000000 | |
| -83.654442,32.825764,0.000000 | |
| -83.653084,32.825729,0.000000 |
This file contains hidden or 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
| # extract JPG files from DBT | |
| # "fail" messages are actually OK | |
| thru = open('samplethru.jfif', 'r') | |
| sc = open('insppict.DBT', 'r') | |
| piccount = 0 | |
| maxpics = 8000 | |
| linecount = 0 | |
| headers = "" | |
| for line in thru: | |
| headers = headers + line |
This file contains hidden or 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
| # scanmatch.py | |
| # Connect photos to their case numbers | |
| import os | |
| photolist = open('photoinfo.csv', 'r') | |
| photosbycase = { } | |
| photonum = 0 | |
| for rawline in photolist: |
This file contains hidden or 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
| # Sign into MySQL | |
| mysql -u root -p | |
| # Create a code enforcement database | |
| CREATE DATABASE codeenf; | |
| USE codeenf; |
This file contains hidden or 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
| # SQLloader.py | |
| # CouchDB JSON import to MySQL | |
| import json, urllib, urllib2 | |
| j = open('propcurrent.json') | |
| for line in j: | |
| case = json.loads(line) | |
This file contains hidden or 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
| # CasePost.py | |
| import urllib, urllib2 | |
| geocases = open('allcasesplusgeo.csv', 'r') | |
| def halfround(dec): | |
| return round(dec * 3, 3) / 3 | |
| # one space each from Jan 1997 to Jun 2012 | |
| cases = [ ] |
This file contains hidden or 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
| # Switch name to nameslug | |
| from PyQt4 import QtCore | |
| activeLayer = qgis.utils.iface.activeLayer() | |
| layerData = activeLayer.dataProvider() | |
| columns = layerData.fields() | |
| # how to determine column keys | |
| for key, value in columns.items(): | |
| print str(key) + " = " + str(value.name()) |