Skip to content

Instantly share code, notes, and snippets.

@robinkraft
robinkraft / tifs.txt
Last active August 29, 2015 14:03
working with rasterio and Apache Spark
>>> '''launch python repl with ./bin/pyspark'''
'launch python repl with ./bin/pyspark'
>>> import rasterio as rio
>>>
>>> def img_size(path):
... with rio.drivers():
... with rio.open(path) as img:
... return [img.width, img.height]
...
>>>
@robinkraft
robinkraft / osgeo_compile.sh
Created June 24, 2014 01:41
compile and install GEOS, PROJ4 and GDAL from source on Ubuntu 12.0.4
# Compile/install GEOS. Taken from:
# http://grasswiki.osgeo.org/wiki/Compile_and_Install_Ubuntu#GEOS_2
cd /tmp
wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2
bunzip2 geos-3.4.2.tar.bz2
tar xvf geos-3.4.2.tar
cd geos-3.4.2
@robinkraft
robinkraft / gist:bb239562aa3194b88030
Last active August 29, 2015 14:01
EcoHackSF 2014 project results

Uses old Android phones to listen for chainsaws. EcoHack 2014 project added realtime SMS alerts & app for park rangers, as well as an impressive dramatization of intended usage.

Android apk
code

Shift your energy use to times when it's green. WattTime started at EcoHackSF 2013, and used EcoHack World to add support for water/carbon impact of energy generation.

@robinkraft
robinkraft / gist:4d1807fb8f9c246b2d21
Last active January 16, 2021 17:42
installing opencv 2.4.10
# install dependencies
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y cmake
sudo apt-get install -y libgtk2.0-dev
sudo apt-get install -y pkg-config
sudo apt-get install -y python-numpy python-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libjpeg-dev libpng-dev libtiff-dev libjasper-dev
@robinkraft
robinkraft / utils-test.py
Created April 19, 2014 02:38
Simple authentication script for Earth Engine API, including a test.
import unittest
from eesetup import utils
class Test(unittest.TestCase):
def setUp(self):
pass
def test_geeAuth(self):
result = utils.geeAuth()
(defn sum-xyz
[]
(<- [?x ?y ?z ?period ?count :> ?x2i ?y2i ?z-new ?sum]
(/ ?x 2 :> ?x2)
(/ ?y 2 :> ?y2)
(math/floor ?x2 :> ?x2i)
(math/floor ?y2 :> ?y2i)
(dec ?z :> ?z-new)
(c/sum ?count :> ?sum)))
@robinkraft
robinkraft / cdm_test.csv
Last active August 29, 2015 13:57
regenerate test data converting CDM to table driving website
x y z p
50064 72706 17 71
50064 72705 17 72
@robinkraft
robinkraft / gist:9625937
Last active August 29, 2015 13:57
n-obs: wrapper for Cascalog's "first-n" operation. Returns N observations of all fields for a given source.
(use 'cascalog.api)
(require '[cascalog.ops :as c])
(defn field-parser
"Convert a string to a fieldname string. If string already
starts with `?` or `!`, return the string directly.
Usage:
(field-parser [\"a\" \"b\"])
;=> [\"?a\" \"?\"]"
@robinkraft
robinkraft / hansen.py
Last active August 29, 2015 13:56
sample script to download UMD forest cover loss data (untested) http://www.earthenginepartners.appspot.com/science-2013-global-forest/download.html
import os
import sys
import requests
basefname = 'Hansen_GFC2013_lossyear_%d%s_%03d%s.tif'
baseurl = 'http://commondatastorage.googleapis.com/earthenginepartners-hansen/GFC2013/%s'
def download(url, output):
/** simple visualization */
#imazon_clean [data_type='defor'] {
polygon-fill:#F69;
polygon-opacity: 1;
line-opacity:1;
line-color: #F69;
line-width: 2;
}
#imazon_clean [data_type='degrad'] {