Last active
March 17, 2021 14:26
-
-
Save danabauer/3b8bc9280b31f84b37c7 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
| ''' | |
| Use case 1 | |
| Scrape the catalog for an AOI/TOI: Filter the RapidEye Grid-UTM catalog for products in an AOI | |
| (United States in Iowa) with an acquisition period between "2014-04-01" and "2014-09-15" with a maximum | |
| cloud cover value of "20%." Download all of the analytic assets. | |
| ''' | |
| import requests | |
| from datetime import datetime | |
| import pytz | |
| import geojson | |
| url = "https://api.planet.com/v1/catalogs/grid-utm-25km-experimental/items/" | |
| key = "YOUR-API-KEY" | |
| #add AOI -- rectangle in Iowa drawn in geojson.io | |
| poly = { | |
| "type": "Polygon", | |
| "coordinates": [ | |
| [ | |
| [ | |
| -95.460205078125, | |
| 41.97174336327968 | |
| ], | |
| [ | |
| -95.460205078125, | |
| 42.17561739661684 | |
| ], | |
| [ | |
| -94.8724365234375, | |
| 42.17561739661684 | |
| ], | |
| [ | |
| -94.8724365234375, | |
| 41.97174336327968 | |
| ], | |
| [ | |
| -95.460205078125, | |
| 41.97174336327968 | |
| ] | |
| ] | |
| ] | |
| } | |
| intersects = geojson.dumps(poly) | |
| #set your filters here For example: cloud cover less than 20% | |
| start = datetime(year=2014, month=4, day=1, tzinfo=pytz.utc).isoformat() | |
| end = datetime(year=2014, month=9, day=15, tzinfo=pytz.utc).isoformat() | |
| cloud = 0.20 | |
| filters = { | |
| "catalog::acquired": start, | |
| "catalog::acquired": end, | |
| "catalog::cloud_cover": cloud, | |
| "intersects": intersects | |
| } | |
| data = requests.get(url, params=filters, auth=(key, '')) | |
| image_data = data.json()["features"] | |
| #show IDs for images that meet criteria | |
| for s in scenes_data: | |
| print s["id"] | |
| #r = requests.get(url, params=filters, auth=(key, '')) | |
| #r.raise_for_status() | |
| #data = r.json() | |
| #for scene in scenes_data: | |
| # thumb_link = scene["properties"]["links"]["thumbnail"] | |
| # download_image(thumb_link, key) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment