Query and download Landsat data from EarthExplorer API using landsatxplore

Frequently Asked Questions
Post Reply
quinten
Posts: 1010
Joined: Tue Mar 03, 2015 8:13 am

Query and download Landsat data from EarthExplorer API using landsatxplore

Post by quinten »

To access Landsat data programmatically there is a public API client for the USGS EarthExplorer written in Python by Yann Forget, available on GitHub. You need to make an EarthExplorer account and can then query and download scenes.

I have used it in a separate environment, e.g.

Code: Select all

conda create -n lxplore -c conda-forge python=3
conda activate lxplore
python -m pip install landsatxplore git+https://github.com/yannforget/landsatxplore
It is then possible to use this environment for the query and download. First set the environment variables:

Code: Select all

conda activate lxplore
export LANDSATXPLORE_USERNAME=<your_username>
export LANDSATXPLORE_PASSWORD=<your_password>
Search, here an example Landsat OLI/TIRS Collection 2 Level 1 data for Oostende:

Code: Select all

landsatxplore search --dataset landsat_ot_c2_l1 --location 51.24 2.91 --start 2023-09-01 --end 2023-09-19
Which outputs:

Code: Select all

LC08_L1GT_199024_20230410_20230420_02_T2
LC09_L1TP_200024_20230409_20230409_02_T1
LC09_L1TP_199024_20230402_20230402_02_T1
LC08_L1GT_200024_20230401_20230411_02_T2
and download:

Code: Select all

landsatxplore download --dataset landsat_ot_c2_l1 LC09_L1TP_200024_20230409_20230409_02_T1
I hope this is useful! Please look at Yann's GitHub for more information!

Quinten
Post Reply