A curated list of open technology projects to sustain a stable climate, energy supply, biodiversity and natural resources.

landsatxplore

Provides an interface to the EarthExplorer portal to search and download Landsat Collections scenes through a command-line interface or a Python API.
https://github.com/yannforget/landsatxplore

Category: Sustainable Development
Sub Category: Environmental Satellites

Keywords

earth-observation landsat remote-sensing

Last synced: about 19 hours ago
JSON representation

Repository metadata

Search and download Landsat scenes from EarthExplorer.

README.md

⚠️ This package is no longer maintained, you are welcome to take over ⚠️


Build
Tests
codecov
DOI

Description

CLI Demo

The landsatxplore Python package provides an interface to the EarthExplorer portal to search and download Landsat Collections scenes through a command-line interface or a Python API.

The following datasets are supported:

Dataset Name Dataset ID
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 2 Level 1 landsat_etm_c2_l1
Landsat 7 ETM+ Collection 2 Level 2 landsat_etm_c2_l2
Landsat 8 Collection 2 Level 1 landsat_ot_c2_l1
Landsat 8 Collection 2 Level 2 landsat_ot_c2_l2
Landsat 9 Collection 2 Level 1 landsat_ot_c2_l1
Landsat 9 Collection 2 Level 2 landsat_ot_c2_l2

Quick start

Searching for Landsat 5 TM scenes that contains the location (12.53, -1.53) acquired during the year 1995.

landsatxplore search --dataset landsat_tm_c2_l1 --location 12.53 -1.53 \
    --start 1995-01-01 --end 1995-12-31

Search for Landsat 7 ETM scenes in Brussels with less than 5% of clouds. Save the returned results in a .csv file.

landsatxplore search --dataset landsat_tm_c2_l2 \
    --location 50.83 4.38 --clouds 5 > results.csv

Downloading three Landsat scenes from different datasets in the current directory.

landsatxplore download LT51960471995178MPS00 LC80390222013076EDC00 LC82150682015350LGN01

To use the package, Earth Explorer credentials are required (registration).

Installation

The package can be installed using pip.

pip install landsatxplore

Usage

landsatxplore can be used both through its command-line interface and as a Python module.

Command-line interface

landsatxplore --help
Usage: landsatxplore [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  download  Download one or several Landsat scenes.
  search    Search for Landsat scenes.

Credentials

Credentials for the Earth Explorer portal can be obtained here.

--username and --password can be provided as command-line options or as environment variables:

export LANDSATXPLORE_USERNAME=<your_username>
export LANDSATXPLORE_PASSWORD=<your_password>

Searching

landsatxplore search --help
Usage: landsatxplore search [OPTIONS]

  Search for Landsat scenes.

Options:
  -u, --username TEXT             EarthExplorer username.
  -p, --password TEXT             EarthExplorer password.
  -d, --dataset [landsat_tm_c1|landsat_etm_c1|landsat_8_c1|landsat_tm_c2_l1|landsat_tm_c2_l2|landsat_etm_c2_l1|landsat_etm_c2_l2|landsat_ot_c2_l1|landsat_ot_c2_l2|sentinel_2a]
                                  Landsat data set.
  -l, --location FLOAT...         Point of interest (latitude, longitude).
  -b, --bbox FLOAT...             Bounding box (xmin, ymin, xmax, ymax).
  -c, --clouds INTEGER            Max. cloud cover (1-100).
  -s, --start TEXT                Start date (YYYY-MM-DD).
  -e, --end TEXT                  End date (YYYY-MM-DD).
  -o, --output [entity_id|display_id|json|csv]
                                  Output format.
  -m, --limit INTEGER             Max. results returned.
  --help                          Show this message and exit.

Downloading

landsatxplore download --help
Usage: landsatxplore download [OPTIONS] [SCENES]...

  Download one or several Landsat scenes.

Options:
  -u, --username TEXT    EarthExplorer username.
  -p, --password TEXT    EarthExplorer password.
  -d, --dataset TEXT     Dataset.
  -o, --output PATH      Output directory.
  -t, --timeout INTEGER  Download timeout in seconds.
  --skip
  --help                 Show this message and exit.

If the --dataset is not provided, the dataset is automatically guessed from the scene identifier. Note that only the newer Landsat Product Identifiers contain information related to collection number and processing level. To download Landsat Collection 2 products, use Product IDs or set the --dataset option correctly.

API

EarthExplorer API

landsatxplore provides an interface to the Earth Explorer JSON API. Please refer to the official (documentation) for possible request codes and parameters.

Basic usage

from landsatxplore.api import API

# Initialize a new API instance and get an access key
api = API(username, password)

# Perform a request. Results are returned in a dictionnary
response = api.request(
    '<request_endpoint>',
    params={
        "param_1": value_1,
        "param_2": value_2
    }
)

# Log out
api.logout()

Please refer to the official JSON API Reference for a list of all available requests.

Searching for scenes

import json
from landsatxplore.api import API

# Initialize a new API instance and get an access key
api = API(username, password)

# Search for Landsat TM scenes
scenes = api.search(
    dataset='landsat_tm_c2_l1',
    latitude=50.85,
    longitude=-4.35,
    start_date='1995-01-01',
    end_date='1995-10-01',
    max_cloud_cover=10
)

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

# Process the result
for scene in scenes:
    print(scene['acquisition_date'].strftime('%Y-%m-%d'))
    # Write scene footprints to disk
    fname = f"{scene['landsat_product_id']}.geojson"
    with open(fname, "w") as f:
        json.dump(scene['spatial_coverage'].__geo_interface__, f)

api.logout()

Output:

4 scenes found.
1995-09-23
1995-08-22
1995-08-15
1995-06-28

Downloading scenes

from landsatxplore.earthexplorer import EarthExplorer

ee = EarthExplorer(username, password)

ee.download('LT51960471995178MPS00', output_dir='./data')

ee.logout()

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 5 days ago

Total Commits: 94
Total Committers: 8
Avg Commits per committer: 11.75
Development Distribution Score (DDS): 0.383

Commits in past year: 1
Committers in past year: 1
Avg Commits per committer in past year: 1.0
Development Distribution Score (DDS) in past year: 0.0

Name Email Commits
Yann y****t@m****g 58
Yann Forget f****1@g****m 16
valpamp 5****p 9
Guido Riembauer r****r@m****e 7
Alexandros Vythoulkas a****s@p****m 1
Veronica Andreo v****o@g****m 1
Hiyam Debary 1****y 1
sjdqbyitr178crs813tgbr8gsdufygeuy53 2****3 1

Committer domains:


Issue and Pull Request metadata

Last synced: 2 days ago

Total issues: 87
Total pull requests: 21
Average time to close issues: 4 months
Average time to close pull requests: 6 months
Total issue authors: 73
Total pull request authors: 19
Average comments per issue: 2.78
Average comments per pull request: 1.29
Merged pull request: 8
Bot issues: 0
Bot pull requests: 0

Past year issues: 6
Past year pull requests: 4
Past year average time to close issues: N/A
Past year average time to close pull requests: about 1 hour
Past year issue authors: 5
Past year pull request authors: 4
Past year average comments per issue: 1.67
Past year average comments per pull request: 0.25
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/yannforget/landsatxplore

Top Issue Authors

  • henrykironde (4)
  • Digdgeo (3)
  • veroandreo (2)
  • Asim12345 (2)
  • jacquesmoati (2)
  • trexbatman (2)
  • ChangpeiHe (2)
  • lastproxy (2)
  • HanDuwol (2)
  • Fenrihr (2)
  • mhmdreza-gp (2)
  • envaidya (1)
  • ESimonson710 (1)
  • hgf777-br (1)
  • TristanMTG (1)

Top Pull Request Authors

  • griembauer (3)
  • jcintasr (1)
  • barneyjackson (1)
  • aamir-s18 (1)
  • bdnorman (1)
  • faendeg (1)
  • williamjr (1)
  • MrChebur (1)
  • veroandreo (1)
  • hiyamdebary (1)
  • anikaweinmann (1)
  • ekcomputer (1)
  • Laughingbi (1)
  • legendjslc (1)
  • AnupaKulathunga (1)

Top Issue Labels

  • enhancement (9)
  • bug (8)

Top Pull Request Labels

  • bug (1)

Package metadata

pypi.org: landsatxplore

Search and download Landsat scenes from EarthExplorer

  • Homepage: https://github.com/yannforget/landsatxplore
  • Documentation: https://github.com/yannforget/landsatxplore
  • Licenses: MIT
  • Latest release: 0.15.0 (published about 2 years ago)
  • Last Synced: 2025-04-25T12:04:39.324Z (2 days ago)
  • Versions: 14
  • Dependent Packages: 1
  • Dependent Repositories: 6
  • Downloads: 1,377 Last month
  • Rankings:
    • Forks count: 4.906%
    • Stargazers count: 5.197%
    • Dependent repos count: 6.115%
    • Average: 6.126%
    • Downloads: 7.103%
    • Dependent packages count: 7.306%
  • Maintainers (1)

Dependencies

pyproject.toml pypi
  • pytest ^6.2 develop
  • pytest-cov ^2.11 develop
  • click ^7.1
  • python ^3.7
  • python-dateutil ^2.8
  • requests ^2.20
  • shapely ^1.7
  • tqdm ^4.58
.github/workflows/python-publish.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v1 composite
.github/workflows/run-tests.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v1 composite

Score: 14.993069569318342