Delete extract.py
Browse files- extract.py +0 -24
extract.py
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
"""
|
2 |
-
Get the collaction of all the metadata of the umbra open data collection
|
3 |
-
"""
|
4 |
-
|
5 |
-
import requests
|
6 |
-
import urllib.parse
|
7 |
-
import json
|
8 |
-
import pystac
|
9 |
-
|
10 |
-
def extract(out_path):
|
11 |
-
|
12 |
-
base_url = 'https://s3.us-west-2.amazonaws.com/umbra-open-data-catalog/stac/'
|
13 |
-
home = 'catalog.json'
|
14 |
-
url = urllib.parse.urljoin(base_url, home)
|
15 |
-
|
16 |
-
collection = {'type': 'FeatureCollection', 'features': []}
|
17 |
-
catalog = pystac.Catalog.from_file(url)
|
18 |
-
for idx, item in enumerate(catalog.get_all_items()):
|
19 |
-
item = item.to_dict()
|
20 |
-
item['assets']['metadata']['content'] = requests.get(item['assets']['metadata']['href']).json()
|
21 |
-
collection['features'].append(item)
|
22 |
-
|
23 |
-
with open(out_path, 'w') as f:
|
24 |
-
json.dump(collection, f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|