Skip to content

Instantly share code, notes, and snippets.

@Seagor
Created April 25, 2016 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Seagor/0f8f7c9e1e1ed63d79b29995efdc8db2 to your computer and use it in GitHub Desktop.
Save Seagor/0f8f7c9e1e1ed63d79b29995efdc8db2 to your computer and use it in GitHub Desktop.
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