Skip to content

Instantly share code, notes, and snippets.

@mmcfarland
Created January 12, 2023 22:31
Show Gist options
  • Save mmcfarland/53d8eeb057bd18e1f9e356cd579bb1e1 to your computer and use it in GitHub Desktop.
Save mmcfarland/53d8eeb057bd18e1f9e356cd579bb1e1 to your computer and use it in GitHub Desktop.
import requests
url = 'https://planetarycomputer.microsoft.com/api/stac/v1/search'
search = {
"collections": [
"sentinel-1-rtc"
],
"bbox": [-121.68811311, 46.83262832, -120.19715332, 47.84592105],
"datetime": "2019-01-01/2019-12-31",
#"fields": { "include": ["id"], "exclude": ["links"]},
"limit": 100
}
r = requests.post(url, json=search)
ids = [item['id'] for item in r.json()['features']]
next = [l for l in r.json()['links'] if l['rel'] == 'next']
while len(next) > 0:
r = requests.post(url, json=next[0]['body'])
next = [l for l in r.json()['links'] if l['rel'] == 'next']
ids += [item['id'] for item in r.json()['features']]
assert(len(ids) == len(set(ids)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment