I have now also implemented a simple query and download system to use EarthExplorer to get Landsat (4/5/7/8/9) data that can be used in ACOLITE processing. This system is now integrated in the ACOLITE code on GitHub and can be freely tested. There are other packages that do a similar thing, e.g.
landsatxplore.
[Edit 2024-04-27] I have now moved the earthexplorer module into ac.api, so change the call in the examples below from ac.earthexplorer to ac.api.earthexplorer
To use the EarthExplorer feature please make an account at
https://earthexplorer.usgs.gov/ and put your credentials in your .netrc file:
Code: Select all
machine earthexplorer
login YOUR_LOGIN
password YOUR_PASSWORD
Make sure your .netrc file has no group or world read access, i.e. -rw-------. You can set this for example by:
Alternatively you can set EARTHEXPLORER_u=YOUR_LOGIN and EARTHEXPLORER_p=YOUR_PASSWORD in either your OS environment variables or in the acolite/config/config.txt file.
After importing ACOLITE:
Code: Select all
import sys, os
user_home = os.path.expanduser("~")
sys.path.append(user_home+'/git/acolite')
import acolite as ac
You can query based on a region of interest (either a WKT string, polygon file or ACOLITE S,W,N,E limit) for a specific sensor type ("tm" for L4/5, "etm" for L7, and "ot" for L8/9). By default "ot", i.e. OLI/TIRS on L8/9 is used. The following example lists urls and scene names with <20% cloud cover over the Blue Accelerator platform near Oostende, Belgium using a simple point WKT:
Code: Select all
entity_list, identifier_list, dataset_list = ac.api.earthexplorer.query(
roi='POINT (2.9192711575039305 51.24648601469525)',
landsat_type = 'ot', start_date = '2023-07-01', end_date = '2023-08-31', cloud_cover = 20)
Note that the cloud cover parameter is the scene wide fraction (0-100) as provided by USGS processing. Scenes with unknown cloud cover are excluded when the cloud_cover filter is active.
These urls/scenes can then be downloaded to a specific directory:
Code: Select all
local_scenes = ac.api.earthexplorer.download(entity_list, dataset_list, identifier_list, output = None)
If output is set to None, scenes will be downloaded in the current working directory, and you may prefer to specify another path to store downloaded scenes. By default the tar files are extracted and deleted after extraction. This can be switched off by passing extract_tar=False and delete_tar=False.
A sample run of the last two examples in a Jupyter notebook after downloading and extracting one of the found scenes:
![EarthExplorer_d.png](./download/file.php?id=580)
- EarthExplorer_d.png (126.26 KiB) Viewed 59375 times
The paths to the local scenes can then be passed to ACOLITE processing, i.e. using ac.acolite.acolite_run(), see for example
here.