Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Filtering Pixels in Leaflet</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<!-- Load Leaflet from CDN-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet/0.7.7/leaflet.css" />
<script src="https://cdn.jsdelivr.net/leaflet/0.7.7/leaflet.js"></script>
@mappingvermont
mappingvermont / results_to_table_brazil_biome.py
Created February 27, 2017 14:31
cumsum loss data for brazil biomes
import os
import csv
import pandas as pd
def main():
header_list = ['biome', 'iso', 'adm1', 'adm2', 'year', 'thresh', 'area_raw', 'emissions_raw']
print 'Reading df'
@mappingvermont
mappingvermont / getting-started.md
Last active March 1, 2017 13:06
Setting up control-tower and a sample microservice
@mappingvermont
mappingvermont / pandas_join.py
Created April 3, 2017 21:36
join pandas DFs and write to CSV using multiprocessing
import feather
import os
import pandas as pd
import multiprocessing
folder_path = r'/home/ubuntu/raster-vector-to-tsv/output/925ff7f3-c08b-4de5-a385-469e0b26975a/final_tsv/'
csv_list = [os.path.join(folder_path, x) for x in os.listdir(folder_path) if os.path.splitext(x)[1] == '.tsv']
@mappingvermont
mappingvermont / combine.sh
Created April 4, 2017 20:56
Combine all shapefiles in directory, selecting only features where GRID_ID (or DN) is = 1
#!/bin/bash
echo "here"
DATA=`find . -name '*.shp'`
ogr2ogr -a_srs EPSG:4326 merge.shp
for i in $DATA
do
SHP=${i:2:100}
FINAL="${SHP/.shp/}"
echo $FINAL
echo $i
@mappingvermont
mappingvermont / multiprocess_raster.py
Created April 10, 2017 16:58
Example downloading + processing raster data with multiple processors
import multiprocessing
import time
tile_list = ['00N_000E', '00N_010E', '00N_020E', '00N_030E', '00N_040E']
def process_tile(tile_id):
print 'downloading loss and extent for tile id {}'.format(tile_id)
time.sleep(1)
import numpy as np
import json
from pprint import pprint
vals = [11, 14, 30, 40, 60, 90, 100, 120, 130, 140, 150, 160, 180, 190, 200, 220]
# number of loss years starting 2000 (=no loss)
years = 15
# number of land cover classes
@mappingvermont
mappingvermont / index.html
Created April 21, 2017 19:19
cambridgeport 1869 beers map
<!DOCTYPE html>
<html>
<head>
<title>Demo Cambridgeport Map</title>
<meta charset="utf-8" />
<link
rel="stylesheet"
href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css"
/>
<style>
@mappingvermont
mappingvermont / index.html
Last active April 26, 2017 14:51
Map of Greenfield MA in 1895
<!DOCTYPE html>
<html>
<head>
<title>Demo Greenfield Map</title>
<meta charset="utf-8" />
<link
rel="stylesheet"
href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css"
/>
<style>
@mappingvermont
mappingvermont / gfw-api-windows.md
Created April 28, 2017 15:45
Running the GFW API on windows

This is a pain. But so is:

  • editing your code locally and pushing it to your linux machine to see if it runs
  • running an ubuntu virtualbox locally
  • editing a complex application on a linux server using nano

Install docker and docker-compose

  1. Make sure that you have windows 10
  2. Install Docker for Windows