Skip to content

Instantly share code, notes, and snippets.

@robinkraft
robinkraft / osgeo_compile.sh
Created Jun 24, 2014
compile and install GEOS, PROJ4 and GDAL from source on Ubuntu 12.0.4
View osgeo_compile.sh
# 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 / projected_area.py
Created Dec 12, 2014
get the area in square meters of a polygon using shapely and pyproj
View projected_area.py
import pyproj
from shapely.geometry import shape
from shapely.ops import transform
geom = {'type': 'Polygon',
'coordinates': [[[-122., 37.], [-125., 37.],
[-125., 38.], [-122., 38.],
[-122., 37.]]]}
s = shape(geom)
View minikube_uninstall.sh
minikube stop; minikube delete &&
docker stop $(docker ps -aq) &&
rm -rf ~/.kube ~/.minikube &&
sudo rm -rf /usr/local/bin/localkube /usr/local/bin/minikube &&
launchctl stop '*kubelet*.mount' &&
launchctl stop localkube.service &&
launchctl disable localkube.service &&
sudo rm -rf /etc/kubernetes/ &&
docker system prune -af --volumes
@robinkraft
robinkraft / s3bucketsize.py
Last active Oct 24, 2021
Simple python script to calculate size of S3 buckets
View s3bucketsize.py
import sys
import boto
# based on http://www.quora.com/Amazon-S3/What-is-the-fastest-way-to-measure-the-total-size-of-an-S3-bucket
# assumes you've already configured your access id & secret key
s3 = boto.connect_s3()
@robinkraft
robinkraft / gist:4d1807fb8f9c246b2d21
Last active Jan 16, 2021
installing opencv 2.4.10
View gist:4d1807fb8f9c246b2d21
# 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 / gist:1413347
Created Dec 1, 2011
the easy way to install GDAL 1.8.0 on Ubuntu
View gist:1413347
sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
sudo apt-get install gdal-bin
sudo apt-get -y install python-gdal
@robinkraft
robinkraft / download.py
Last active Apr 20, 2020
Unofficial client for the Planet.com satellite image catalog and API, originally part of Planet's quickstart guides. https://developers.planet.com/docs/quickstart/
View download.py
#!/usr/bin/env python
import argparse
import os
import requests
import json
import sys
import logging
import datetime
@robinkraft
robinkraft / load_hdf.py
Created Feb 10, 2012
Load hdf file with GDAL and Python, get NDVI
View load_hdf.py
from osgeo import gdal
import os
layer_dict = {"reli":"reliability", "qual":"Quality", "ndvi":"NDVI", "evi":"EVI"}
def print_data(layer, data):
print data
print "data:", layer
print "type:", data.dtype
print "mean:", data.mean()
@robinkraft
robinkraft / domino_event_log_5c777df946e0fb0008ada92c_condensed.json
Created Feb 28, 2019
cat ~/Downloads/domino_event_log_5c777df946e0fb0008ada92c.json | jq ".[].description"
View domino_event_log_5c777df946e0fb0008ada92c_condensed.json
"Request to deploy app with id 5c777df946e0fb0008ada92c"
"Deploying app with id 5c777df946e0fb0008ada92c"
"Deployment created: run-5c777df946e0fb0008ada92c"
"Pod created: run-5c777df946e0fb0008ada92c-6794d486b8-sxsp4"
"Scaled up replica set run-5c777df946e0fb0008ada92c-6794d486b8 to 1"
"Successfully assigned run-5c777df946e0fb0008ada92c-6794d486b8-sxsp4 to ip-10-0-175-133.us-west-2.compute.internal"
"Pod updated: run-5c777df946e0fb0008ada92c-6794d486b8-sxsp4"
"Deployment updated: run-5c777df946e0fb0008ada92c"
"Deployment updated: run-5c777df946e0fb0008ada92c"
"Pod updated: run-5c777df946e0fb0008ada92c-6794d486b8-sxsp4"
@robinkraft
robinkraft / instructions.md
Last active Jan 16, 2019
Burn scar algorithm for Google Earth Engine, derived from Elvidge and Baugh (2014).
View instructions.md

Set up for update

  1. Go to fires download page - https://firms.modaps.eosdis.nasa.gov/download/
  2. Zoom to Sumatra. It doesn't have to be perfect. We do some screening in EE to make sure there are no fires in Malaysia used.
  3. Submit the download request (2013-03-30 to present) - csv is easiest - then wait for it to complete (usually < 30 minutes)
  4. Upload the CSV file to Fusion Tables. Go here, then just click "new table" under the File menu and follow the instructions.
  5. Get the docid from the url. For example, for docid=1SzJl73nj5IPVEOGqhGc8uv5Vkwb504uqK_YTnVGh just grab 1SzJl73nj5IPVEOGqhGc8uv5Vkwb504uqK_YTnVGh
  6. Update dates in this script when you run it on EE - the second date in the POST variable may need to be extended.
  7. Update the FIRES variable to equal to "ft:". You'll see how it is in the code.

Run + export