Skip to content

Instantly share code, notes, and snippets.

View arthur-e's full-sized avatar

K. Arthur Endsley arthur-e

View GitHub Profile

Managing the PostgreSQL Service

The service name is postgresql and it accepts the usual commands for a background service:

  • start
  • stop
  • restart
  • status
@arthur-e
arthur-e / seedrecovery.py
Last active August 29, 2015 13:57
Tool(s) to recover the Markdown contents from an older Springseed *.note file.
'''
Recover the Markdown content of an older Springseed note (*.note) file. Output
*.md file names will be the name of the Note file prepended by the Notebook
name, if available.
'''
import sys
import os
import re
import json
@arthur-e
arthur-e / colorBrewer.js
Created April 10, 2014 12:21
Generates higher-contrast sequential or diverging color palettes based on Cynthia Brewer's colors; outputs the same format as d3/lib/colorbrewer but colors are higher-contrast.
chroma = require('./node_modules/chroma-js/chroma.min.js');
function generatePalettes (type, reversed) {
var n, m;
var paletteNames;
var palettes = {};
if (type === 'sequential') {
paletteNames = [
'BuGn', 'BuPu', 'GnBu', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'RdPu',

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)
# Credit goes to my colleague Tyler (http://tylerickson.blogspot.com/2011/09/installing-gdal-in-python-virtual.html)
ENVDIR=/usr/local/pythonenv/
ENVNAME=nasabaer-env
OWNER=arthur
# Install GEOS if necessary
# sudo apt-get libgeos-3.2.2 libgeos-dev
# Install GDAL on the system

Introduction

Drivers

These are the exact names that OGR recognizes; in parentheses are the file extensions, not to be included in the driver name:

  • ESRI Shapefile (*.shp)
  • KML (*.kml)
  • AVCE00 (*.e00)
  • AVCBin
@arthur-e
arthur-e / Stats.js
Last active December 26, 2015 22:08 — forked from clauswitt/Stats.js
A JavaScript function ("class") that returns an object which can be used to calculate statistics on the the passed numeric Array.
/**
Returns an object which can be used to calculate statistics on the
the passed numeric Array.
*/
var Stats = function (arr) {
arr = arr || [];
// http://en.wikipedia.org/wiki/Mean#Arithmetic_mean_.28AM.29
this.arithmeticMean = function () {
var i, sum = 0;
@arthur-e
arthur-e / deaths_malaria.txt
Last active January 12, 2016 20:48
Prevalence of current tobacco use among adults (>=15 years) (%) both sexes, columns are: country name, 2002 prevalence (%), 2005 prevalence (%); all data from GapMinder.org
country 2000 2001 2002 2003 2004 2005 2006
Algeria 0 0 0
Angola 96 66 98 254 80 86 62
Benin 10 6 9 7 11 4 16
Botswana 2 2 1 1 1 1 2
Burkina Faso 23 35 32 37 31 37 56
Burundi 9 6 7 6 9 25 5
Cameroon 5 5
Cape Verde 0 0 0 0 0 1
Central African Republic 14 10 21 16 20
@arthur-e
arthur-e / aggregation.Rmd
Last active August 6, 2016 19:10
A comparison of aggregation methods in R using the Gapminder data from Data Carpentry
---
title: "Aggregation in R"
author: "K. Arthur Endsley"
date: "August 4, 2016"
output: html_document
---
Let's explore multiple ways to aggregate data in R.
We'll do this to answer two questions:
@arthur-e
arthur-e / raster_learning.py
Created March 10, 2017 21:06
An example Python script of using scikit-learn to learn water from non-water pixels
'''
A module for machine learning on Landsat data; implemented and tested,
specifically, for learning water areas on an image. Performance so far:
Gaussian naive Bayes (where validation data chosen by the hydro mask):
Mean precision: Not water=0.9997, Water=0.3090
Mean recall: Not water=0.9787, Water=0.9763
Gaussian naive Bayes (where validation data inspected in Google Earth):
Mean precision: Not water=0.9675, Water=1.0000