yannforget / landsatxplore

Search and download Landsat scenes from EarthExplorer.
MIT License
217 stars 95 forks source link

api.search() not returning level 2 products #89

Open jeremy-cesbio opened 1 year ago

jeremy-cesbio commented 1 year ago

This package is very simple and intuitive to use, thank you !

I have an issue that probably has a simple answer that I can't find: the search function only returns level 1 products for landsat 7, 8 and landsat 9 Collection 2. Here is an example of my script :

from landsatxplore.api import API
import geopandas as gpd

shapefile = '/home/my_shapefile.shp'

gpd_shape = gpd.read_file(shapefile)
gpd_shape = gpd_shape.to_crs(epsg='4326')  # Force WGS84 projection
bounds = gpd_shape.geometry.total_bounds

# Initialize a new API instance and get an access key
api = API('my_id', 'my_pass')

# Search for Landsat TM scenes
scenes = api.search(
    dataset='landsat_ot_c2_l2',
    bbox=list(bounds),
    start_date='2020-01-01',
    end_date='2020-10-01',
    max_cloud_cover=80
)

print(f"{len(scenes)} scenes found.")

for scene in scenes:
    print(scene['acquisition_date'])
    print(scene['landsat_product_id'])

And here is the return (identical to the return where dataset='landsat_ot_c2_l1'):

26 scenes found.
2020-09-17 00:00:00
LC08_L1TP_198031_20200917_20201005_02_T1
2020-09-08 00:00:00
LC08_L1TP_199031_20200908_20200919_02_T1
2020-09-01 00:00:00
LC08_L1TP_198031_20200901_20200906_02_T1
2020-08-23 00:00:00
LC08_L1TP_199031_20200823_20200905_02_T1
2020-08-16 00:00:00
LC08_L1TP_198031_20200816_20200920_02_T1
2020-08-07 00:00:00
LC08_L1TP_199031_20200807_20200916_02_T1
2020-07-31 00:00:00
LC08_L1TP_198031_20200731_20200908_02_T1
2020-07-22 00:00:00
LC08_L1TP_199031_20200722_20200911_02_T1
2020-07-15 00:00:00
LC08_L1TP_198031_20200715_20200912_02_T1
2020-07-06 00:00:00
LC08_L1TP_199031_20200706_20200913_02_T1
2020-06-29 00:00:00
LC08_L1TP_198031_20200629_20200823_02_T1
2020-06-20 00:00:00
LC08_L1TP_199031_20200620_20200823_02_T1
...
2020-01-12 00:00:00
LC08_L1TP_199031_20200112_20200824_02_T1
2020-01-05 00:00:00
LC08_L1TP_198031_20200105_20200823_02_T1

The dates and tiles are correct but I'm looking for the LC08L2SP... products.

Thanks in advance

hiewliwen commented 1 year ago

Change the dataset ID to the L2 according to the table.

# Search for Landsat TM scenes
scenes = api.search(
    dataset='landsat_ot_c2_l2', <-- CHANGE THIS
Dataset Name Dataset ID
Landsat 5 TM Collection 1 Level 1 landsat_tm_c1
Landsat 5 TM Collection 2 Level 1 landsat_tm_c2_l1
Landsat 5 TM Collection 2 Level 2 landsat_tm_c2_l2
Landsat 7 ETM+ Collection 1 Level 1 landsat_etm_c1
Landsat 7 ETM+ Collection 2 Level 1 landsat_etm_c2_l1
Landsat 7 ETM+ Collection 2 Level 2 landsat_etm_c2_l2
Landsat 8 Collection 1 Level 1 landsat_8_c1
Landsat 8 Collection 2 Level 1 landsat_ot_c2_l1
Landsat 8 Collection 2 Level 2 landsat_ot_c2_l2
Sentinel 2A sentinel_2a
jeremy-cesbio commented 1 year ago

But I precisely want the Landsat 8 Collection 2 Level 2 products (i.e. landsat_ot_c2_l2), but the search function returns the Level 1 products...

envaidya commented 7 months ago

This looks like an old thread, but is there any solution to this? I am facing same issue. With "scenes = api.search( dataset='landsat_ot_c2_l2'", the files downloaded are all Level 1 (L1) only! How can I only download L2 data? Thanks.

jeremy-cesbio commented 7 months ago

I ended up adapting the script from this link to my usage (USGS Machine-to-Machine (M2M) API), didn't take too much time.