Skip to content

Instantly share code, notes, and snippets.

@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()
@robinkraft
robinkraft / upload.py
Last active December 7, 2017 20:50
Upload a raster to mapbox.com using the Mapbox Upload API
from mapbox import Uploader
u = Uploader() # handles authentication
tileset = 'username.tileset_name' # name your tileset
url = u.stage(open('mosaic_final.tif')) # upload happens here
u.create(url, tileset, name=fname) # starts the tiling job
@robinkraft
robinkraft / firemap.html
Last active October 13, 2017 17:40
Embed code for fire map
<iframe src="https://api.mapbox.com/styles/v1/robinkraft/cj8nn4lvp7yoq2ro1klhjltw8.html?title=true&access_token=pk.eyJ1Ijoicm9iaW5rcmFmdCIsImEiOiJQLUp2RU9NIn0.B20c6fiHx0NCgfSOE3HYbw#13.15/38.4816/-122.7019" width="640" height="480”>
@robinkraft
robinkraft / prep_data.py
Last active June 29, 2017 22:46
Script to process dogs vs. cats data from Kaggle for use with VGG ImageNet submission. See https://www.kaggle.com/c/dogs-vs-cats-redux-kernels-edition/
import os
import random
import glob
import shutil
def get_dc_paths(path):
"""Given a path filled with dog & cat files, make separate lists of both."""
cats = []
dogs = []
@robinkraft
robinkraft / toa_reflectance.py
Created January 20, 2017 03:15
calculate toa reflectance for Planet Labs data - not an ideal script, but you get the idea
import os
import argparse
from bs4 import BeautifulSoup
import rasterio
SUFFIX = '_BGRN_Analytic'
BASEPATH = '/Users/robinkraft/gitlab/change/hackathon/robin/data/'
@robinkraft
robinkraft / learning_rates.ipynb
Last active November 29, 2016 03:17
Showing difference between different methods for changing learning rates in Keras.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@robinkraft
robinkraft / prep_data.py
Last active November 21, 2016 01:46
Data prep for Kaggle's State Farm competition
import os
from glob import glob
import shutil
import pandas as pd
def choose_subjects(df, count):
# group the frame by the subject in the image
subjects = df.groupby('subject')
@robinkraft
robinkraft / gfw2_layerstyles_v4.css
Created December 6, 2013 18:15
CartoCSS styling for layers on gfw-beta.org. Backup current as of 2013-12-06 10:15am PST
/** this cartoCSS has been processed in order to be compatible with the new cartodb 2.0 */
#gfw2_layerstyles_v4{
polygon-fill:#FF6600;
polygon-opacity: 0.7;
line-width: 0.2;
line-opacity:0.6;
line-color: #ccc;
[zoom>3]{
line-width: 0.3;
<html>
<head>
<title>D3 Axis Example</title>
<script src="http://d3js.org/d3.v3.js"></script>
</head>
<body>
<script>
var width = 700,
@robinkraft
robinkraft / humid.json
Last active December 19, 2015 15:29
Animated globe and humid tropics, Angola in green.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.