This file contains 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
#!/bin/sh | |
"exec" "twxec" "-e" "filter_stream()" "$0" "$@" | |
import oauth2 as oauth | |
from trickle import twitter as tw | |
{{docstring "Make sure you have registered an application with Twitter in order to obtain your credentials. Once you have them, start streaming tweets using one of the filtering parameteres below"}} | |
app_key = {{string Twitter_App_Key}} | |
app_secret = {{string Twitter_App_Secret}} |
This file contains 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
#!/bin/sh | |
"exec" "twxec" "-e" "filter_stream()" "$0" "$@" | |
import oauth2 as oauth | |
from trickle import twitter as tw | |
{{docstring "Make sure you have registered an application with Twitter in order to obtain your credentials. Once you have them, start streaming tweets using one of the filtering parameteres below"}} | |
app_key = {{string Twitter_App_Key}} | |
app_secret = {{string Twitter_App_Secret}} |
This file contains 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 | |
areas = [] | |
for i, img in enumerate(found_objects): | |
for r, reg in enumerate(img): | |
for cnt in reg['contours']: | |
areas.append((cv2.contourArea(cnt), r, i)) | |
df = pd.DataFrame(data = areas, columns=['area', 'dock', 'image']) |
This file contains 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 cv2 | |
from skimage.morphology import binary_opening | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import matplotlib | |
matplotlib.style.use('ggplot') | |
%matplotlib inline | |
This file contains 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
normalize = lambda x: (255 / (x.max() - x.min())) * (x - x.min()) | |
smooth = lambda x: ndimage.convolve(x, np.ones([3,3])/9) | |
def threshold_mask(img, threshold=150): | |
gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) | |
mask = np.ones(gray.shape).astype(np.uint8) | |
mask[gray < threshold] = 0 | |
return mask | |
def scanline_mask(imask): |
This file contains 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 numpy as np | |
import cv2 | |
from skimage import measure | |
from skimage.measure import regionprops | |
from skimage.morphology import skeletonize, convex_hull_image, medial_axis, opening | |
from scipy import ndimage | |
def seg_buffer(im, dist=25): | |
mask = im.copy() |
This file contains 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 planet import api | |
import sys, os | |
import urllib2, httplib | |
%matplotlib inline | |
import matplotlib.pyplot as plt | |
import matplotlib.image as mpimg | |
class NoRedirection(urllib2.HTTPErrorProcessor): | |
def http_response(self, request, response): |
This file contains 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 gevent | |
from planet import api | |
import geojson | |
bbox = {{ string bbox }} | |
minx, miny, maxx, maxy = None, None, None, None | |
if bbox is not None: | |
minx, miny, maxx, maxy = bbox.split(',') | |
if minx is not None: |
This file contains 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 rasterio | |
%matplotlib inline | |
import matplotlib.pyplot as plt | |
import numpy as np | |
def render_array(arr1, arr2=None, width=7, height=7, cmap=plt.cm.jet): | |
if arr2 is None: | |
fig, ax = plt.subplots(1, figsize=(width,height), facecolor='white') |
This file contains 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 cv2 | |
import numpy as np | |
%matplotlib inline | |
import matplotlib.pyplot as plt | |
def buffer_coastline(img, threshold=135): | |
arr = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) | |
mask = np.ndarray(arr.shape + (3,)).astype(np.uint8) | |
below = arr < threshold |
NewerOlder