[ Launch: uk geo hackery ] 5827283 by danhammer[ Launch: uk geo hackery ] 5825795 by robinkraft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
""" | |
This script updates our MODIS data archive stored on S3 based on what's | |
available on NASA's MODIS data FTP server (e4ftl01u.ecs.nasa.gov) | |
The MODIS FTP server is organized by product then date, in the format | |
/MODIS_Composites/MOLT/MOD13A3.005/2000-02-01. This corresponds to the Terra | |
(MOLT) vegetation indices product at 1000m resolution, 32-day composites, | |
for the month of February 2000. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import urllib | |
import csv | |
from shapely.geometry import Point | |
from shapely.prepared import prep | |
import ee | |
import os | |
import ee.mapclient | |
import requests, zipfile, StringIO | |
import Image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import forma | |
import ee | |
from bbox_tiler import bbox | |
from globalmaptiles import GlobalMercator | |
def coordsToTiles(lon, lat): | |
# Convert the supplied latitude and longitude coordinates to | |
# mercator tiles at zoom level 16, ready for upload to CartoDB. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def construct_query(iso, fmt = 'shp'): | |
# Builds the API call to download FORMA in various formats Other | |
# acceptable formats are 'csv', 'GeoJSON', 'JSON', 'kml', or 'svg' | |
base = "http://wri-01.cartodb.com/api/v2" | |
var = "x,y,date_array" | |
sql = "SELECT %s FROM gfw2_forma WHERE iso = '{%s}'" % (var, iso) | |
query = "%s/sql?format=%s&q=%s" % (base, fmt, sql) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(zoo) | |
library(stats) | |
library(dtw) | |
library(timeDate) | |
library(lubridate) | |
library(reshape) | |
library(randomForest) | |
clean.pixels <- function(filename, dir) { | |
## accepts output from Pavel's script and returns a data frame with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def formatPolygon(coords): | |
"""Accepts a set of coordinates, in sequence, and checks that they | |
are formatted counter-clockwise; returns an Earth Engine polygon. | |
Works for non-convex polygons.""" | |
def _edger(c0, c1): | |
# anonymous function to generate the edge value between | |
# coordinate tuples `c0` and `c1` | |
x0, y0 = c0 | |
x1, y1 = c1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import requests | |
import json | |
import pandas as pd | |
# Go from JSON to a measurement of UMD deforestation by year. If you | |
# have a shapefile, you will have to convert and simplify the | |
# polygons, preserving topology. The Earth Engine API does not | |
# support long, long requests. You can convert the shapefile using | |
# OGR within the data subdirectory: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import pandas | |
from BeautifulSoup import BeautifulSoup | |
def _grab_data(): | |
url = 'http://www.bettermap.org/json' | |
x = requests.get(url) | |
return x.json()['features'] | |
def _process_entry(entry): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import json | |
import pandas as pd | |
# Process information on Caltrans projects. Convert this file to | |
# GeoJSON: | |
# wget https://dot.ca.gov/hq/construc/cons.kml | |
# ogr2ogr -f GeoJSON cons.json cons.kml |