Skip to content

Instantly share code, notes, and snippets.

View gist:9085520
/** simple visualization */
#imazon_clean [data_type='defor'] {
polygon-opacity: 1;
line-color: #F69;
line-width: 2;
#imazon_clean [data_type='degrad'] {
import os
import sys
import requests
basefname = 'Hansen_GFC2013_lossyear_%d%s_%03d%s.tif'
baseurl = ''
def download(url, output):
robinkraft / gist:9625937
Last active Aug 29, 2015
n-obs: wrapper for Cascalog's "first-n" operation. Returns N observations of all fields for a given source.
View gist:9625937
(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.
(field-parser [\"a\" \"b\"])
;=> [\"?a\" \"?\"]"
robinkraft / cdm_test.csv
Last active Aug 29, 2015
regenerate test data converting CDM to table driving website
View cdm_test.csv
x y z p
50064 72706 17 71
50064 72705 17 72
View gist:9800089
(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 / gist:bb239562aa3194b88030
Last active Aug 29, 2015
EcoHackSF 2014 project results
View gist:bb239562aa3194b88030

Rainforest Connection

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

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 / tifs.txt
Last active Aug 29, 2015
working with rasterio and Apache Spark
View tifs.txt
>>> '''launch python repl with ./bin/pyspark'''
'launch python repl with ./bin/pyspark'
>>> import rasterio as rio
>>> def img_size(path):
... with rio.drivers():
... with as img:
... return [img.width, img.height]
robinkraft /
Last active Aug 29, 2015
Extracting polygons from GEE
import ee
# based on
def main():
# speciesData = ee.FeatureCollection(
# 'ft:14QQnwJVRPYXdhb4sRqaDblVRclbMxmew1rQCYig6')
# collection = ee.ImageCollection(
# 'MODIS/MOD13Q1').filterDate('2000-02-24', '2014-07-01')
robinkraft /
Created Aug 5, 2014
precache images for crowdsourcing app
import sys
import requests
import multiprocessing
URL = ''
def f(a):
r = requests.get(URL)
robinkraft / gist:05205edbd978de84873c
Last active Aug 29, 2015
revised GFW queries for UMD loss/gain data
View gist:05205edbd978de84873c
# global sum of loss and gain by year
# note that the gain is the same each year (it is total gain / 12), so if you want total gain
# you need to add up all the gain values, or multiply one of them by 12
SELECT year,
Sum(loss) loss,
Sum(gain) gain
FROM umd_nat
WHERE thresh = 10
AND year > 2000