|
| 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