Skip to content

Instantly share code, notes, and snippets.

View ateucher's full-sized avatar

Andy Teucher ateucher

View GitHub Profile
print("Hello!")
@ateucher
ateucher / test.geojson
Last active June 28, 2016 02:41
rgdal::readOGR / GDAL 2.1.0 bug test
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
brew tap osgeo/osgeo4mac
brew install gdal2
## Put in the PATH
echo 'export PATH=$(brew --prefix)/opt/gdal2/bin:$(brew --prefix)/bin:$PATH' >> ~/.bash_profile
@ateucher
ateucher / hb_ds_rudis
Created October 11, 2016 19:46
Homebrew Data Science Setup
# From Bob Rudis (@hrbmstr): https://rud.is/b/2015/10/22/installing-r-on-os-x-100-homebrew-edition/
brew tap caskroom/cask
brew install brew-cask
brew install Caskroom/cask/xquartz
brew cask install java
brew tap homebrew/science
brew install R --with-openblas # added --with-openblas based on a spiffy comment by Lincoln Mullen
@ateucher
ateucher / GDAL_with_python
Last active November 28, 2016 23:26
Various gis setup tips on Windows
Install Python (Anaconda is easiest)
As explained here: https://pythongisandstuff.wordpress.com/2016/04/13/installing-gdal-ogr-for-python-on-windows/,
download the compiled GDAL from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
Then:
$ pip install GDAL-blah-blah.whl
If fiona (https://github.com/Toblerity/Fiona) is required, download it from http://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona and install it the same way.
@ateucher
ateucher / move_files.py
Last active October 25, 2016 18:19
In a folder full of files, subsets of which have the same base filename but different extensions (e.g., foo.txt, foo.csv, foo.tar.gz, bar.txt, bar.csv, bar.tar.gz), create folders based on the base filename (e.g., foo, bar) and move the files into the appropriate folders.
### Usage:
# Copy this file into the directory containing the files,
# open a terminal/cmd prompt in that directory, and type:
# python move_files.py
import os
question = "Would you like to move all of the files in '" + os.getcwd() + "' into subfolders? (y/n)"
answer = raw_input(question)
@ateucher
ateucher / parse_bc_directory.R
Last active November 10, 2016 18:22
Parse BC Govt Directory to a list, and search for a name
library(xml2)
bc_dir <- read_xml("http://dir.gov.bc.ca/downloads/BCGOV_directory.xml")
find_person <- function(nm) {
search_string <- sprintf("//d1:PERSON/d1:NAME[contains(text(), \"%s\")]", nm)
matches <- xml_find_all(bc_dir, search_string)
if (length(matches) == 0) {
message("No matches found")
@ateucher
ateucher / bc_geocode.R
Created November 17, 2016 17:50
BC Geocoder in R
# http://api.bcdevexchange.org/api-console.html?swaggerUrl=https://raw.githubusercontent.com/bcgov/api-specs/master/geocoder/geocoder.json#/
library(httr)
base_url <- function() "http://apps.gov.bc.ca/pub/geocoder"
endpoint <- "addresses"
format <- "json"
brew unlink gdal
brew tap osgeo/osgeo4mac && brew tap --repair
brew install gdal2 --with-armadillo \
--with-complete --with-libkml --with-unsupported
brew link --force gdal2
# Verify