Acess available dates for Landsat 8/9 -collection is not available

Hello,

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

Hi Reut,

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.

Therefore you need to use https://services-uswest2.sentinel-hub.com as endpoint url https://docs.sentinel-hub.com/api/latest/data/landsat-8/#catalog-api-capabilities

you can easily specify that in the config object as such:

config.sh_base_url='https://services-uswest2.sentinel-hub.com'

Best regards

1 Like

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

MissingSchema: Invalid URL ‘services-uswest2.sentinel-hub.com/api/v1/catalog/search’: No schema supplied. Perhaps you meant http://services-uswest2.sentinel-hub.com/api/v1/catalog/search?

I’m a little but confused why this needed.

Best regards :slight_smile:

Just right here as you set the credentials

config = SHConfig()

config.sh_base_url='https://services-uswest2.sentinel-hub.com'    

and then go on to run the rest of your 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)

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

Based on the error message,
the catalog and config variables, need to be declared atleast for each of the if statements.

if collection==DataCollection.SENTINEL2_L2A:
     
        config = SHConfig()
        config.sh_base_url='https://services.sentinel-hub.com' 
        catalog = SentinelHubCatalog(config=config)
elif collection==DataCollection.LANDSAT_OT_L2:
        config = SHConfig()
        config.sh_base_url='https://services-uswest2.sentinel-hub.com' 
        catalog = SentinelHubCatalog(config=config)
1 Like