|
""" |
|
Get the collaction of all the metadata of the umbra open data collection |
|
""" |
|
|
|
import requests |
|
import urllib.parse |
|
import json |
|
import pystac |
|
|
|
def extract(out_path): |
|
|
|
base_url = 'https://s3.us-west-2.amazonaws.com/umbra-open-data-catalog/stac/' |
|
home = 'catalog.json' |
|
url = urllib.parse.urljoin(base_url, home) |
|
|
|
collection = {'type': 'FeatureCollection', 'features': []} |
|
catalog = pystac.Catalog.from_file(url) |
|
for idx, item in enumerate(catalog.get_all_items()): |
|
item = item.to_dict() |
|
item['assets']['metadata']['content'] = requests.get(item['assets']['metadata']['href']).json() |
|
collection['features'].append(item) |
|
|
|
with open(out_path, 'w') as f: |
|
json.dump(collection, f) |