Skip to content

Instantly share code, notes, and snippets.

View Nate-Wessel's full-sized avatar
🍁

Nate Wessel Nate-Wessel

🍁
View GitHub Profile
@Nate-Wessel
Nate-Wessel / gaussian.js
Created February 3, 2022 18:45
Gaussian function
// https://en.wikipedia.org/wiki/Gaussian_function
const [height,center,bandwidth] = [1,0,1]
function kernel(x){
return height*Math.exp( - ( ((x-center)**2)/(2*bandwidth**2) ) )
}
@Nate-Wessel
Nate-Wessel / the-equator.geojson
Created July 13, 2020 19:22
A geojson file for the equator
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Nate-Wessel
Nate-Wessel / divided-highways-overpass.txt
Created September 10, 2019 18:52
overpass query finding parts of split/divided highways - very slow query at present
// identify 3-way intersections of identically named ways
// thus to identify/located divided/split roadways
// get nodes of all named ways
way[highway][name]({{bbox}})->.namedways;
// foreach way
foreach .namedways -> .thisway(
node(w.thisway)->.childnodes;
foreach.childnodes -> .thisnode(
// select named parent ways of this node with the same name
@Nate-Wessel
Nate-Wessel / sidewalk-no-crossing.txt
Created September 7, 2019 15:43
Overpass API query to select sidewalks directly intersecting streets without crossings
way[highway][highway!~"footway|service|path|cycleway|steps|pedestrian"]({{bbox}});
node(w);
way(bn)[highway=footway][footway=sidewalk];
out body;
>;
out skel qt;
@Nate-Wessel
Nate-Wessel / old-building-query.txt
Created September 5, 2019 00:17
Overpass query to select buildings in hamilton county not recently edited.
[timeout:600];
// Hamilton County area by id
rel(104784); map_to_area->.ham;
// get older buildings inside the county
way(area.ham)[building](if: timestamp() < "2014-08-25")->.buildings;
// iterate over buildings, checking the dates on their nodes
foreach .buildings->.way {
// only add ways to the result set if nodes are also
@Nate-Wessel
Nate-Wessel / rename.py
Created August 28, 2018 19:30
Python3 batch file rename
import os
from_path = '/home/nate/Dropbox/muni-17477/'
to_path = '/home/nate/Dropbox/muni-17477-fixed/'
old_files = os.listdir(from_path)
for old_file in old_files:
old_fpath = from_path+old_file
with open(old_fpath,'r') as fp:
old_content = fp.read()
old_hour = old_file[11:13]
new_hour =str(int(old_hour)-3)
@Nate-Wessel
Nate-Wessel / conversion.txt
Created July 26, 2018 17:01
formula for converting openoffice calc timestamp to unix timestamp
=(cell-25569)*86400 - hour_offset*3600
@Nate-Wessel
Nate-Wessel / inner_angle_plane.py
Created March 9, 2018 18:29
Python function for calculating a planar inner angle of three points
def inner_angle_plane(point1,point2,point3):
"""Given three points, p1
calculate the smaller of the two angles \ a
formed by the sequence. \
Returns degrees. p2------p3
Input is three (x,y) tuples
"""
# be sure there IS an angle to measure
assert point1 != point2 and point2 != point3
# get coordinate values
@Nate-Wessel
Nate-Wessel / OxD batch itinerary request.py
Created December 22, 2017 13:50
OxD multithreaded requests to OTP itinerary API
import requests, json, psycopg2, multiprocessing, time, os
from random import shuffle
from datetime import datetime, timedelta
fileroot = 'itins/jv/sched-all-stops/'
# define the start time
start_time = datetime( year=2017, month=11, day=10 )
print 'from ', start_time
@Nate-Wessel
Nate-Wessel / tesselate-points.r
Last active January 28, 2018 23:55
centroidal voronoi tesselation of a set of points
# this script takes a set of points, in this case bus stops
# and does a centroidal voronoi tesselation weighted by
# those points from an initial uniform random seeding. The effect
# is an even-ish distribution of sample points accross the space.
# My goal is to use these as representative ODs for a travel time
# matrix that effectively samples a whole transit network.
library('deldir') # voronoi stuff
library('rgdal') # projections
library('sp') # spatial data types