Is it possible to use sentinel-1-rtc with the Data API mosaic endpoint? #276
-
I tried modifying the data api example notebook to use display the following search as a mosaic on a folium map. Rendering single items as tile layers works fine. But I'm unable to get the mosaic to work. I see a lot of 404 and 500 errors in the console but am not noticing anything obviously wrong with the tiles URL: Could this be an issue with the SAS token requirement for RTC compared to the example using sentinel-2 ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Looks like a quoting issue. The URLs from the Explorer look like
While the tilejson generated by the notebook is
Notice that the Edit: This is a bit ugly, but seems to work: import pystac_client
import requests
import itertools
def key(s):
return s.split("=")[0]
COLLECTION = "sentinel-1-rtc"
catalog = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1"
)
aoi = {
"type": "Polygon",
"coordinates": [
[
[-123.60492153752948, 46.04968244060868],
[-118.68923696942923, 46.04968244060868],
[-118.68923696942923, 48.57164306792697],
[-123.60492153752948, 48.57164306792697],
[-123.60492153752948, 46.04968244060868]
]
]
}
# Define your temporal range
daterange = {"interval": ["2023-10-01T00:28:21Z", "2023-10-05T23:59:59Z"]}
# Define your search with CQL2 syntax
search = catalog.search(filter_lang="cql2-json", filter={
"op": "and",
"args": [
{"op": "s_intersects", "args": [{"property": "geometry"}, aoi]},
{"op": "anyinteracts", "args": [{"property": "datetime"}, daterange]},
{"op": "=", "args": [{"property": "collection"}, COLLECTION]}
]
})
r_register = requests.post(
"https://planetarycomputer.microsoft.com/api/data/v1/mosaic/register",
json=search.get_parameters(),
)
registered = r_register.json()
registered
tilejson_url = registered["links"][1]["href"]
mosaic_info = requests.get(
"https://planetarycomputer.microsoft.com/api/data/v1/mosaic/info",
params=dict(collection=COLLECTION),
).json()
render_config = mosaic_info["renderOptions"][0]
render_config
params = {k: [x.split("=")[1] for x in v] for k, v in itertools.groupby(render_config["options"].split("&"), key=key)}
params["collection"] = COLLECTION
r_tiles = requests.get(
tilejson_url,
params=params
)
r_tiles.raise_for_status()
tiles = r_tiles.json()["tiles"][0]
tiles I don't know why, but Python's urllib.parse.parse_qs is converting the def key(s):
return s.split("=")[0]
params = {k: [x.split("=")[1] for x in v] for k, v in itertools.groupby(render_config["options"].split("&"), key=key)} |
Beta Was this translation helpful? Give feedback.
Looks like a quoting issue. The URLs from the Explorer look like