Skip to content

Instantly share code, notes, and snippets.

@dfwarden
dfwarden / dfw_createtopology.sql
Created May 16, 2020 03:00
This is a slight modifcation of pgr_createTopology() and _pgr_pointToId() based on https://github.com/pgRouting/pgrouting/wiki/Create-Topology-With-Z-Levels-at-Intersections that creates topology vertices with discrete z-levels. An example dataset that is structured in this way is the New York State "Streets" dataset from https://gis.ny.gov/gisd…
/*PGR-GNU*****************************************************************
Copyright (c) 2015 pgRouting developers
Author: Stephen Woodbridge <woodbri@imaptools.com>
Author: Vicky Vergara <vicky_vergara@hotmail,com>
Mail: project@pgrouting.org
------
This program is free software; you can redistribute it and/or modify
@dfwarden
dfwarden / mount-bitlocker
Created November 1, 2018 13:54 — forked from dumbledore/mount-bitlocker
Mount/umount wrapper for dislocker on MacOS
#!/bin/bash
BITLOCKER_PARTITION="${1}"
BITLOCKER_PASSWORD="${2}"
function usage() {
echo "$(basename ${0}) <partition> <password>"
echo "Unlocks and mounts a bitlocker partition as read-only"
}
if [ -z "${BITLOCKER_PARTITION}" ]
@dfwarden
dfwarden / PostGIS_LinestringZ_Curvature.sql
Created January 17, 2016 21:35
Get sum of change in degrees between the 2 line segments in every trigram of points in a LinestringZ as proxy for curvature.
select
ogc_fid,
sum(degrees(atan2(opposite, adjacent))) as delta_degrees
from
(select
ogc_fid,
point_idx,
st_3ddistance(unit_tangent_endpoint, unit_vector_endpoint) as opposite,
st_3ddistance(common_point, unit_vector_endpoint) as adjacent
from
@dfwarden
dfwarden / gist:b68df8f8722fdbf1c443
Created January 10, 2016 15:36
PostGIS New LinestringZ from Linestring w/Raster Sample
/*
We have to build a new replacement LinestringZ rather than use
ST_SetPoint() since UPDATE can only change a single row, and
the column type in question is LinestringZ, not PointZ.
*/
select st_astext(st_makeline(
array(select st_makepoint(st_x(point), st_y(point), z) as new_point
from
(select st_pointn(wkb_geometry, point_idx) as point,
st_value(rast, st_pointn(wkb_geometry, point_idx)) as z
@dfwarden
dfwarden / gapps-groupssettings-adminexample.py
Created April 30, 2013 14:14
Example of administrative OAuth 2.0 access to Google Group Settings API.
import httplib2
import oauth2client.client
import pprint
from apiclient.discovery import build
serviceacct_email = "<your service account email address>"
f = file('groupssettings-privatekey.p12', 'rb')
client_key = f.read()
f.close()