Closed wwoodgate closed 1 year ago
Hey @wwoodgate! Yeah, I have to admit I chose products for this notebook that didn't require a key to avoid this whole issue... 😅 It's a great idea though - some guidance on accessing data that requires an API key would be really useful to include here. Will have a think and see what we can work out!
@wwoodgate Any chance you could share some extra details about what issues you've run into with the Planetary Computer API keys? I might have a theory about what's going wrong, and want to test it out.
Hey @robbibt, I always got stuck with the "HTTPError: 403 Client Error: Forbidden for url: ..." when searching the item collection, even after adding a custom header with my API key:
Create custom headers including the Authorization header with the API key headers = { 'Authorization': f'Bearer {api_key}', } Initialize the STAC client client = Client.open(stac_api_url, headers=headers)
But I've never done anything like this before so didn't have a working example to go by.
Hey @wwoodgate, I've been able to load data from Sentinel-1 on the Sandbox - here's the steps I followed:
planetarycomputer configure
. When prompted, paste in your copied API key:
import pystac_client
import planetary_computer
import odc.stac
from dea_tools.dask import create_local_dask_cluster client = create_local_dask_cluster(return_client=True)
catalog = pystac_client.Client.open( "https://planetarycomputer.microsoft.com/api/stac/v1", modifier=planetary_computer.sign_inplace, )
bbox = (153.110, -26.841, 153.153, -26.803)
search = catalog.search(
collections=["sentinel-1-rtc"], bbox=bbox, datetime="2023-08-01/2023-09-09"
)
items = search.item_collection()
print(f"Found {len(items)} items")
ds = odc.stac.load( items, bbox=bbox, bands=["vv", "vh"], crs="utm", resolution=10, groupby="solar_day", chunks={}, )
ds.load()
ds.isel(time=0).vv.plot(robust=True)
![image](https://github.com/GeoscienceAustralia/dea-notebooks/assets/17680388/e40c5786-786b-4c98-9a2a-6752064319ef)
If you run into any issues, I'd try restarting your notebook kernel after you configure your API, then trying again!
Nailed it @robbibt ! This works perfectly. I'll teach this in tomorrow's prac :)
No issues and didn't need to restart the notebook, very smooth.
Many thanks!! Will
Hi DEA team,
First, I love the addition of the Planetary computer notebook. However, some PC products require an API subscription key to open (more permissioned).
If you could provide some suggestions or code as to how to implement this in the current notebook (if feasible) that would be fantastic.
For example, accessing S1 radar RTC data would be ace (https://planetarycomputer.microsoft.com/dataset/sentinel-1-rtc ). Here's a discussion that may be relevant (https://github.com/microsoft/PlanetaryComputer/discussions/167) - I hit a dead end there even though I have a PC account and API key..
Cheers, Will