Skip to content

Instantly share code, notes, and snippets.

View arthur-e's full-sized avatar

K. Arthur Endsley arthur-e

View GitHub Profile
import numpy as np
def reflective_kde(x_data: np.ndarray, x_prediction: np.ndarray) -> np.ndarray:
h = silverman_bandwidth(x_data) # Compute before adding reflected data
x_data_augmented = np.stack((-x_data, x_data, 2-x_data))
reflective_densities = basic_kde(x_data_augmented, x_prediction, h)
# Discard left and right reflected samples and normalize density by 1/3
return 3 * reflective_densities

Apparently even a difference of the least precision of the upper left-hand corner causes an alignment error in PostGIS. Consider this example, where I am comparing a land cover raster subset by an MTBS raster and the MTBS raster itself (with the goal being to add the latter to the former, creating the "burned" land cover).

```
SELECT ST_MetaData(r1.rast)
  FROM
(SELECT rast
   FROM geowepp_burnedarea
  WHERE geowepp_burnedarea.rid = 2) r1
UNION
SELECT ST_MetaData(r2.rast)
@danhammer
danhammer / trends.py
Created August 11, 2012 00:01
Python implementation of FORMA trend processing
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active March 27, 2024 06:33
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@sgillies
sgillies / geo_interface.rst
Last active April 10, 2024 00:26
A Python Protocol for Geospatial Data

Author: Sean Gillies Version: 1.0

Abstract

This document describes a GeoJSON-like protocol for geo-spatial (GIS) vector data.

Introduction

@springmeyer
springmeyer / install-tilemill-latest.sh
Last active April 7, 2022 20:00
install bleeding edge tilemill, nodejs, and mapnik
# First, clear out any old mapnik or node.js installs that might conflict
sudo apt-get purge libmapnik libmapnik-dev mapnik-utils nodejs
# Also clear out any old ppa's that might conflict
sudo rm /etc/apt/sources.list.d/*mapnik*
sudo rm /etc/apt/sources.list.d/*developmentseed*
sudo rm /etc/apt/sources.list.d/*chris-lea*
# add new ppa's
echo 'yes' | sudo apt-add-repository ppa:chris-lea/node.js
@clauswitt
clauswitt / Stats.js
Created October 13, 2011 20:47
Simple statistics for javascript
function Stats(arr) {
var self = this;
var theArray = arr || [];
//http://en.wikipedia.org/wiki/Mean#Arithmetic_mean_.28AM.29
self.getArithmeticMean = function() {
var sum = 0, length = theArray.length;
for(var i=0;i<length;i++) {
sum += theArray[i];
}
# Graham Scan - Tom Switzer <thomas.switzer@gmail.com>
TURN_LEFT, TURN_RIGHT, TURN_NONE = (1, -1, 0)
def turn(p, q, r):
return cmp((q[0] - p[0])*(r[1] - p[1]) - (r[0] - p[0])*(q[1] - p[1]), 0)
def _keep_left(hull, r):
while len(hull) > 1 and turn(hull[-2], hull[-1], r) != TURN_LEFT:
hull.pop()