Closed weiji14 closed 2 years ago
An iterable-style DataPipe to make STAC API queries to dynamic STAC Catalogs! Uses pystac-client to perform the STAC API Item Search on the /search endpoint.
/search
Preview at https://zen3geo--59.org.readthedocs.build/en/59/api.html#zen3geo.datapipes.PySTACAPISearch
Usage (requires planetary-computer>=0.4.7 and pystac-client>=0.5.0):
planetary-computer>=0.4.7
pystac-client>=0.5.0
import planetary_computer from torchdata.datapipes.iter import IterableWrapper from zen3geo.datapipes import PySTACAPISearch # Peform STAC API query using DataPipe query = dict( bbox=[174.5, -41.37, 174.9, -41.19], datetime=["2012-02-20T00:00:00Z", "2022-12-22T00:00:00Z"], collections=["cop-dem-glo-30"], ) dp = IterableWrapper(iterable=[query]) dp_pystac_client = dp.search_for_pystac_item( catalog_url="https://planetarycomputer.microsoft.com/api/stac/v1", modifier=planetary_computer.sign_inplace, ) # Loop or iterate over the DataPipe stream it = iter(dp_pystac_client) stac_item_search = next(it) stac_items = list(stac_item_search.items()) print(stac_items) # [<Item id=Copernicus_DSM_COG_10_S42_00_E174_00_DEM>] print(stac_items[0].properties) # {'gsd': 30, # 'datetime': '2021-04-22T00:00:00Z', # 'platform': 'TanDEM-X', # 'proj:epsg': 4326, # 'proj:shape': [3600, 3600], # 'proj:transform': [0.0002777777777777778, # 0.0, # 173.9998611111111, # 0.0, # -0.0002777777777777778, # -40.99986111111111]}
TODO:
pystac_client.Client.open
pystac-client
pystac
STAC_URL
Part of https://github.com/weiji14/zen3geo/discussions/48.
References:
An iterable-style DataPipe to make STAC API queries to dynamic STAC Catalogs! Uses pystac-client to perform the STAC API Item Search on the
/search
endpoint.Preview at https://zen3geo--59.org.readthedocs.build/en/59/api.html#zen3geo.datapipes.PySTACAPISearch
Usage (requires
planetary-computer>=0.4.7
andpystac-client>=0.5.0
):TODO:
pystac_client.Client.open
pystac_client.Client.open
workspystac-client
as a dependency and not bothpystac
andpystac-client
?STAC_URL
environment variable works~ (actually no, becauseSTAC_URL
no longer works, see https://github.com/stac-utils/pystac-client/pull/81, patch update at https://github.com/stac-utils/pystac-client/pull/317)Part of https://github.com/weiji14/zen3geo/discussions/48.
References: