Skip to content

Instantly share code, notes, and snippets.

View kuanb's full-sized avatar
🚌
trains, buses, bikes, and maps

Kuan Butts kuanb

🚌
trains, buses, bikes, and maps
View GitHub Profile
@drmalex07
drmalex07 / convert-geojson-to-wkt.py
Created May 12, 2014 22:13
Convert GeoJSON to/from WKT in Python. #python #geojson #geometry
import json
import geojson
from shapely.geometry import shape
o = {
"coordinates": [[[23.314208, 37.768469], [24.039306, 37.768469], [24.039306, 38.214372], [23.314208, 38.214372], [23.314208, 37.768469]]],
"type": "Polygon"
}
s = json.dumps(o)
@bbengfort
bbengfort / nx2gt.py
Created June 26, 2016 12:01
Convert a networkx to graph-tool graph
import networkx as nx
import graph_tool as gt
def get_prop_type(value, key=None):
"""
Performs typing and value conversion for the graph_tool PropertyMap class.
If a key is provided, it also ensures the key is in a format that can be
@ximeg
ximeg / ThresholdingAlgo.py
Created April 20, 2017 07:20
Python implementation of smoothed z-score algorithm from http://stackoverflow.com/a/22640362/6029703
#!/usr/bin/env python
# Implementation of algorithm from http://stackoverflow.com/a/22640362/6029703
import numpy as np
import pylab
def thresholding_algo(y, lag, threshold, influence):
signals = np.zeros(len(y))
filteredY = np.array(y)
avgFilter = [0]*len(y)
stdFilter = [0]*len(y)
@jenningsanderson
jenningsanderson / daylight_osm_distribution_parquet.md
Last active October 4, 2023 15:12
"Analysis Ready" Daylight OSM Distribution Available on AWS

What are the Daylight OpenStreetMap Parquet Files?

Listed on the registry of Open Data on AWS, the Daylight OpenStreetMap Parquet files contain the latest Daylight Map Distribution of OpenStreetMap in an analysis-ready format. This dataset is optimized for cloud-based queries with Amazon Athena, meaning anyone can access the entire dataset with SQL queries in the browser, without the need to download or access the files directly.

The Daylight Map Distribution of OpenStreetMap is always openly available for download in the standard OSM PBF format (find it at daylightmap.org). The parquet files, however, were first made available alongside Daylight release v1.9. They contain fully resolved geometries and additional metadata including areas, lengths, and quadkeys, not present in the PBF.

In total, the OSM features files contain nearly 1B features including 178M+ nodes, 816M+ ways, and 5M+ relations. These are all _renderable f

from math import sqrt
from matplotlib import pyplot
from shapely.geometry import *
GM = (sqrt(5)-1.0)/2.0
W = 8.0
H = W*GM
SIZE = (W, H)
COLORS = ['#6699cc', '#ffcc33']
@drewda
drewda / gist:1299198
Created October 19, 2011 18:23
Jenks natural breaks classification
# code from http://danieljlewis.org/files/2010/06/Jenks.pdf
# described at http://danieljlewis.org/2010/06/07/jenks-natural-breaks-algorithm-in-python/
def getJenksBreaks( dataList, numClass ):
dataList.sort()
mat1 = []
for i in range(0,len(dataList)+1):
temp = []
for j in range(0,numClass+1):
temp.append(0)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zachallaun
zachallaun / todobot.py
Created November 7, 2014 19:36
Zulip TODO bot
import zulip
import os
import json
client = zulip.Client(config_file='.config', verbose=True)
class TodoManager(object):
def __init__(self, client):
self.client = client
self.todo_file = ".todos"