Created
April 25, 2016 20:26
-
-
Save Seagor/0f8f7c9e1e1ed63d79b29995efdc8db2 to your computer and use it in GitHub Desktop.
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 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: | |
nw = (float(minx), float(maxy)) | |
se = (float(maxx), float(miny)) | |
ne = (se[0], nw[1]) | |
sw = (nw[0], se[1]) | |
poly = geojson.Polygon([[nw, ne, se, sw, nw]]) | |
intersects = geojson.dumps(poly) | |
else: | |
center = {{ string CenterXY }} | |
if center is not None: | |
x, y = center.split(',') | |
else: | |
x, y = (-117, 40) | |
intersects = 'POINT({} {})'.format(x, y) | |
scene_type = {{ string Scene_Type ["ortho", "rapideye", "landsat"] }} or 'ortho' | |
api_key = {{ string API_Key }} | |
def fetch_metadata(): | |
client = api.Client(api_key) | |
r = client.get_scenes_list(scene_type=scene_type, intersects=intersects) | |
for s in r.iter(): | |
for scene in s.get()['features']: | |
yield scene |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment