Skip to content

Instantly share code, notes, and snippets.

View AndrewTheTM's full-sized avatar
🏃‍♂️

Andrew Rohne AndrewTheTM

🏃‍♂️
View GitHub Profile
# NOTE: There's a post that will be on siliconcreek.net about this someday soon.
import os
map_list = [
{'fieldname': 'final_accessibility_auPkRetail', 'Legend Name': 'Peak Auto Accessibility to Retail', 'qryZero': False, 'tablename': 'final_accessibility', 'precision': 4},
{'fieldname': 'final_accessibility_auPkTotal', 'Legend Name': 'Peak Auto Accessibility to Total Emp.', 'qryZero': False, 'tablename': 'final_accessibility', 'precision': 4},
{'fieldname': 'final_accessibility_auOpRetail', 'Legend Name': 'Off-Peak Auto Accessibility to Retail', 'qryZero': False, 'tablename': 'final_accessibility', 'precision': 4},
{'fieldname': 'final_accessibility_auOpTotal', 'Legend Name': 'Off-Peak Auto Accessibility to Total Emp.', 'qryZero': False, 'tablename': 'final_accessibility', 'precision': 4},
{'fieldname': 'final_accessibility_trPkRetail', 'Legend Name': 'Peak Transit Accessibility to Retail', 'qryZero': False, 'tablename': 'final_accessibility', 'precision': 4},
@AndrewTheTM
AndrewTheTM / get_centroid.py
Created January 27, 2022 16:19
I'm putting this here for posterity. This is how pretty accurate centroids can be determined from a set of points. This was originally written using the shapefile library, and I no longer need it in my code because I'm switching everything to the geopandas package (because of another step that needs geoprocessing that the shapefile library doesn…
def getCentroidFromPoints(self, s):
points = s.points
p_x = 0
p_y = 0
pp = np.array(s.points)
pp = np.append(pp, [pp[0]], axis = 0)
area = self.shoelace(pp)
for p in range(0, len(pp) - 1):
p_x += (pp[p, 0] + pp[p + 1, 0])*(pp[p, 0] * pp[p + 1, 1] - pp[p + 1, 0] * pp[p, 1])
p_y += (pp[p, 1] + pp[p + 1, 1])*(pp[p, 0] * pp[p + 1, 1] - pp[p + 1, 0] * pp[p, 1])
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 2 13:05:58 2020
@author: andrew.rohne
"""
import socket
def setLights(setting):
# NeoPixel library strandtest example
# Author: Tony DiCola (tony@tonydicola.com)
#
# Direct port of the Arduino NeoPixel library strandtest example. Showcases
# various animations on a strip of NeoPixels.
import time
from neopixel import *
let tweet = function(){
Twitter.post('statuses/update', {
status: 'Random Number: ' + Math.random()
}, function(err, data, response){
if(err !== undefined){
console.log('err: ' + err);
}
});
}
library(xkcd)
library(ggplot2)
# Load the font from https://github.com/shreyankg/xkcd-desktop/blob/master/Humor-Sans.ttf
windowsFonts(HS=windowsFont("Humor Sans"))
airplaneSeats1 = data.frame(Width = pnorm(seq(0,1,0.025), mean = 0.5, sd = 0.1) * 10)
airplaneSeats1$label = "Avg American Width"
airplaneSeats1$time = as.integer(row.names(airplaneSeats1)) + 1975
library(openxlsx)
library(ggplot2)
library(reshape2)
library(plyr)
# Fix the path!
cd = read.xlsx("countdata.xlsx", "Sheet1")
# Summarize counts to get average weekdays
cntByDay.1 = ddply(cd, .(DayOfWeek, CntTimeTxt), summarize, NB = mean(NB), SB = mean(SB))
@AndrewTheTM
AndrewTheTM / KExample.r
Created December 6, 2013 14:50
Code used to illustrate effects of K factors.
########################################
# K Factor Example #
########################################
# Apply the gravity model
gravity<-function(T0,f,k){
Zones=nrow(T0)
T1<-matrix(0,Zones,Zones)
for(i in 1:Zones){
P=sum(T0[i,])
@AndrewTheTM
AndrewTheTM / gravmodel.r
Created November 25, 2013 13:27
Gravity model example
# Test data for Philip A. Viton's examples from
# http://facweb.knowlton.ohio-state.edu/pviton/courses2/crp5700/Gravity-beamer.pdf
# ARohne 11/22/2013
Zones=3
#Trip data
T0<-matrix(0,Zones,Zones)
T0[1,1]=100
T0[1,2]=350
@AndrewTheTM
AndrewTheTM / HbwPkCountyFlowMap.R
Created November 20, 2013 19:08
R Markdown script to create a county-county flow map (work in progress!)
Home Based Work Peak Period County-County Trip Flows
========================================================
```{r fig.width=8, fig.height=8}
#,echo=FALSE,message=FALSE,results='hide',warning=FALSE}
library(rgdal)
library(foreign)
#T is our GIS drive, C:\\Modelrun\\... is the model run folder
counties<-readOGR("T:\\GIS\\OKI\\Counties","Counties")