Skip to content

Commit 49edd3a

Browse files
committed
Merge branch 'development' of github.com:ICESat2-SlideRule/sliderule-python into development
2 parents c97e707 + f3ec204 commit 49edd3a

File tree

2 files changed

+55
-22
lines changed

2 files changed

+55
-22
lines changed

utils/build_arctic_dem_mosaics_index.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,17 @@
2020
collection_stac = 'https://pgc-opendata-dems.s3.us-west-2.amazonaws.com/arcticdem/mosaics/v3.0/2m.json'
2121
col = pystac.read_file(collection_stac)
2222

23-
catalog_links = []
2423
item_list = []
2524

2625
for link in col.links:
2726
if link.rel == pystac.RelType.CHILD:
28-
catalog_links.append(link.target)
27+
subcat = pystac.read_file(link.target)
28+
print(subcat)
2929

30-
print(f"Number of tiles: {len(catalog_links)}")
31-
32-
cnt = 0
33-
34-
for link in catalog_links:
35-
subcat = pystac.read_file(link)
36-
print(subcat)
37-
# cnt += 1
38-
# if cnt == 20:
39-
# break
40-
41-
# the call on catalog get_all_items() should find all items/features from this and all child catalog and collections
42-
# for some reason the recursion breaks with an error that item does not have property get_all_items()
43-
# this may be caused by bug in pystac or related to how data is presented for arcticdem, don't know
44-
# item_list = list(subcat.get_all_items())
45-
46-
for _link in subcat.links:
47-
if _link.rel == pystac.RelType.CHILD:
48-
item = pystac.read_file(_link.target)
49-
item_list.append(item)
30+
for _link in subcat.links:
31+
if _link.rel == pystac.RelType.CHILD:
32+
item = pystac.read_file(_link.target)
33+
item_list.append(item)
5034

5135
print(f"Number of features: {len(item_list)}")
5236

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Build index file list and create vrt
3+
import geopandas as gpd
4+
import numpy as np
5+
import pandas as pd
6+
import pystac
7+
8+
9+
###############################################################################
10+
# MAIN
11+
###############################################################################
12+
13+
if __name__ == '__main__':
14+
15+
# catalog_stac = 'https://pgc-opendata-dems.s3.us-west-2.amazonaws.com/pgc-data-stac.json'
16+
# cat = pystac.read_file(catalog_stac)
17+
# arcticdem_collection = cat.get_child('arcticdem')
18+
# mosaic_collection = arcticdem_collection.get_child('arcticdem-mosaics')
19+
20+
collection_stac = 'https://pgc-opendata-dems.s3.us-west-2.amazonaws.com/arcticdem/mosaics/v3.0/2m.json'
21+
col = pystac.read_file(collection_stac)
22+
23+
item_list = []
24+
cnt = 0
25+
26+
for link in col.links:
27+
if link.rel == pystac.RelType.CHILD:
28+
subcat = pystac.read_file(link.target)
29+
print(subcat)
30+
# if cnt == 2:
31+
# break
32+
# cnt += 1
33+
34+
for _link in subcat.links:
35+
if _link.rel == pystac.RelType.CHILD:
36+
item = pystac.read_file(_link.target)
37+
dem = item.to_dict()['assets']['dem']['href']
38+
dem = dem.replace(".", "", 1)
39+
path = link.target.replace("https:/", "/vsis3")
40+
path = path.replace(".s3.us-west-2.amazonaws.com", "", 1)
41+
path = path.replace(".json", dem)
42+
item_list.append(path)
43+
44+
print(f"Number of features: {len(item_list)}")
45+
46+
with open('/data/ArcticDem/mosaic_vrt_list.txt', 'w') as f:
47+
for line in item_list:
48+
f.write(f"{line}\n")
49+

0 commit comments

Comments
 (0)