i’m trying to get dates of available landsat 8/9 images (level 2-atmospherically corrected).
I have used this function:
def get_dates(time_interval,bbox,collection):
catalog = SentinelHubCatalog(config=config)
tiles = list(catalog.search(
collection=collection,
time=time_interval,
bbox=bbox
))
dates = [parse_time(t['properties']['datetime']) for t in tiles]
return dates
lan8_dates=get_dates(time_interval,bbox,DataCollection.LANDSAT_OT_L2)
But I get this message:
DownloadFailedException: Failed to download from: https://services…
with HTTPError:
404 Client Error: Not Found for url: …
Server response: “{“code”:404,“description”:“Collection not found.”}”
I’m not sure what cause this error. I can see that this function works when I use sentinel 2 but not landsat, but I don’t know what is the reason.
My end goal is to get the dates availability of Landsat 8/9
The error suggests that the data you are searching for is not found in the endpoint url specified . Note that Landsat data are stored in US-west region of aws.
Hi @dorothyrono , thanks for the quick answer! what do you mean to specify that in the config object?
When I set up credentials for use I use:
config = SHConfig()
and inside the function I use, I’m not sure if that should come instead of the catatlog item
catalog = SentinelHubCatalog(config=config)
#need to ce changged to this in case of landsat?
config.sh_base_url='services-uswest2.sentinel-hub.com'
When I do this I got error:
def get_dates2(time_interval,bbox,collection):
#I changes the url based on erro I recieved with the one you suggested)
config.sh_base_url='http://services-uswest2.sentinel-hub.com/api/v1/catalog/search?'
catalog = SentinelHubCatalog(config=config)
tiles = list(catalog.search(
collection=collection,
time=time_interval,
bbox=bbox
))
dates = [parse_time(t['properties']['datetime']) for t in tiles]
return dates
Thank you. that worked, but now I understand that the challenge is different;
I want to use this function in order to get dates of sentinel 2 and landsat 8 (each time changing the datacollection.
I’m thinking to add the config as parameter like this:
def get_dates(time_interval,bbox,collection):
if collection==DataCollection.SENTINEL2_L2A:
catalog = SentinelHubCatalog(config=config)
tiles = list(catalog.search(
collection=collection,
time=time_interval,
bbox=bbox
))
dates = [parse_time(t['properties']['datetime']) for t in tiles]
elif collection==DataCollection.LANDSAT_OT_L2:
config = SHConfig()
config.sh_base_url='https://services-uswest2.sentinel-hub.com'
tiles = list(catalog.search(
collection=collection,
time=time_interval,
bbox=bbox
))
return dates
but is giving this error
UnboundLocalError: local variable ‘catalog’ referenced before assignment