{"id":13585115,"url":"https://github.com/yannforget/landsatxplore","last_synced_at":"2025-04-04T16:12:47.851Z","repository":{"id":31838574,"uuid":"129143997","full_name":"yannforget/landsatxplore","owner":"yannforget","description":"Search and download Landsat scenes from EarthExplorer.","archived":false,"fork":false,"pushed_at":"2023-12-01T06:48:00.000Z","size":452,"stargazers_count":212,"open_issues_count":58,"forks_count":92,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-06-11T17:25:53.048Z","etag":null,"topics":["earth-observation","landsat","remote-sensing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yannforget.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-04-11T19:30:41.000Z","updated_at":"2024-06-09T06:13:21.000Z","dependencies_parsed_at":"2023-12-24T16:52:15.533Z","dependency_job_id":null,"html_url":"https://github.com/yannforget/landsatxplore","commit_stats":{"total_commits":93,"total_committers":7,"mean_commits":"13.285714285714286","dds":0.3763440860215054,"last_synced_commit":"8f5db15b77ab0864bb71bc943e67934c4c9f2fb9"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannforget%2Flandsatxplore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannforget%2Flandsatxplore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannforget%2Flandsatxplore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannforget%2Flandsatxplore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yannforget","download_url":"https://codeload.github.com/yannforget/landsatxplore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247092376,"owners_count":20882218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["earth-observation","landsat","remote-sensing"],"created_at":"2024-08-01T15:04:45.013Z","updated_at":"2025-04-04T16:12:47.834Z","avatar_url":"https://github.com/yannforget.png","language":"Python","funding_links":[],"categories":["Python","`Python` processing of optical imagery (non deep learning)","Sustainable Development"],"sub_categories":["Download","Environmental Satellites"],"readme":"⚠️ **This package is no longer maintained, you are welcome to take over** ⚠️ \n\n---\n[![Build](https://img.shields.io/github/workflow/status/yannforget/landsatxplore/Upload%20Python%20Package?label=build\u0026logo=github)](https://github.com/yannforget/landsatxplore/actions/workflows/python-publish.yml)\n[![Tests](https://img.shields.io/github/workflow/status/yannforget/landsatxplore/Run%20tests?label=tests\u0026logo=github)](https://github.com/yannforget/landsatxplore/actions/workflows/run-tests.yml)\n[![codecov](https://codecov.io/gh/yannforget/landsatxplore/branch/master/graph/badge.svg?token=NwVo09Edur)](https://codecov.io/gh/yannforget/landsatxplore)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1291422.svg)](https://zenodo.org/record/4543601)\n\n# Description\n\n![CLI Demo](https://raw.githubusercontent.com/yannforget/landsatxplore/master/demo.gif?s=0.5)\n\nThe **landsatxplore** Python package provides an interface to the [EarthExplorer](http://earthexplorer.usgs.gov/) portal to search and download [Landsat Collections](https://landsat.usgs.gov/landsat-collections) scenes through a command-line interface or a Python API.\n\nThe following datasets are supported:\n\n\n| Dataset Name | Dataset ID |\n|-|-|\n| Landsat 5 TM Collection 2 Level 1 | `landsat_tm_c2_l1` |\n| Landsat 5 TM Collection 2 Level 2 | `landsat_tm_c2_l2` |\n| Landsat 7 ETM+ Collection 2 Level 1 | `landsat_etm_c2_l1` |\n| Landsat 7 ETM+ Collection 2 Level 2 | `landsat_etm_c2_l2` |\n| Landsat 8 Collection 2 Level 1 | `landsat_ot_c2_l1` |\n| Landsat 8 Collection 2 Level 2 | `landsat_ot_c2_l2` |\n| Landsat 9 Collection 2 Level 1 | `landsat_ot_c2_l1` |\n| Landsat 9 Collection 2 Level 2 | `landsat_ot_c2_l2` |\n\n# Quick start\n\nSearching for Landsat 5 TM scenes that contains the location (12.53, -1.53) acquired during the year 1995.\n\n```\nlandsatxplore search --dataset landsat_tm_c2_l1 --location 12.53 -1.53 \\\n    --start 1995-01-01 --end 1995-12-31\n```\n\nSearch for Landsat 7 ETM scenes in Brussels with less than 5% of clouds. Save the returned results in a `.csv` file.\n\n```\nlandsatxplore search --dataset landsat_tm_c2_l2 \\\n    --location 50.83 4.38 --clouds 5 \u003e results.csv\n```\n\nDownloading three Landsat scenes from different datasets in the current directory.\n\n```\nlandsatxplore download LT51960471995178MPS00 LC80390222013076EDC00 LC82150682015350LGN01\n```\n\nTo use the package, Earth Explorer credentials are required ([registration](https://ers.cr.usgs.gov/register)).\n\n# Installation\n\nThe package can be installed using pip.\n\n```\npip install landsatxplore\n```\n\n# Usage\n\n**landsatxplore** can be used both through its command-line interface and as a Python module.\n\n## Command-line interface\n\n```\nlandsatxplore --help\n```\n\n```\nUsage: landsatxplore [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n  --help  Show this message and exit.\n\nCommands:\n  download  Download one or several Landsat scenes.\n  search    Search for Landsat scenes.\n```\n\n### Credentials\n\nCredentials for the Earth Explorer portal can be obtained [here](https://ers.cr.usgs.gov/register/).\n\n`--username` and `--password` can be provided as command-line options or as environment variables:\n\n``` shell\nexport LANDSATXPLORE_USERNAME=\u003cyour_username\u003e\nexport LANDSATXPLORE_PASSWORD=\u003cyour_password\u003e\n```\n\n### Searching\n\n```\nlandsatxplore search --help\n```\n\n```\nUsage: landsatxplore search [OPTIONS]\n\n  Search for Landsat scenes.\n\nOptions:\n  -u, --username TEXT             EarthExplorer username.\n  -p, --password TEXT             EarthExplorer password.\n  -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]\n                                  Landsat data set.\n  -l, --location FLOAT...         Point of interest (latitude, longitude).\n  -b, --bbox FLOAT...             Bounding box (xmin, ymin, xmax, ymax).\n  -c, --clouds INTEGER            Max. cloud cover (1-100).\n  -s, --start TEXT                Start date (YYYY-MM-DD).\n  -e, --end TEXT                  End date (YYYY-MM-DD).\n  -o, --output [entity_id|display_id|json|csv]\n                                  Output format.\n  -m, --limit INTEGER             Max. results returned.\n  --help                          Show this message and exit.\n```\n\n### Downloading\n\n```\nlandsatxplore download --help\n```\n\n```\nUsage: landsatxplore download [OPTIONS] [SCENES]...\n\n  Download one or several Landsat scenes.\n\nOptions:\n  -u, --username TEXT    EarthExplorer username.\n  -p, --password TEXT    EarthExplorer password.\n  -d, --dataset TEXT     Dataset.\n  -o, --output PATH      Output directory.\n  -t, --timeout INTEGER  Download timeout in seconds.\n  --skip\n  --help                 Show this message and exit.\n```\n\nIf 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.\n\n\n## API\n\n### EarthExplorer API\n\n**landsatxplore** provides an interface to the Earth Explorer JSON API. Please refer to the official ([documentation](https://earthexplorer.usgs.gov/inventory/documentation/json-api)) for possible request codes and parameters.\n\n#### Basic usage\n\n``` python\nfrom landsatxplore.api import API\n\n# Initialize a new API instance and get an access key\napi = API(username, password)\n\n# Perform a request. Results are returned in a dictionnary\nresponse = api.request(\n    '\u003crequest_endpoint\u003e',\n    params={\n        \"param_1\": value_1,\n        \"param_2\": value_2\n    }\n)\n\n# Log out\napi.logout()\n```\n\nPlease refer to the official [JSON API Reference](https://m2m.cr.usgs.gov/api/docs/json/) for a list of all available requests.\n\n#### Searching for scenes\n\n``` python\nimport json\nfrom landsatxplore.api import API\n\n# Initialize a new API instance and get an access key\napi = API(username, password)\n\n# Search for Landsat TM scenes\nscenes = api.search(\n    dataset='landsat_tm_c2_l1',\n    latitude=50.85,\n    longitude=-4.35,\n    start_date='1995-01-01',\n    end_date='1995-10-01',\n    max_cloud_cover=10\n)\n\nprint(f\"{len(scenes)} scenes found.\")\n\n# Process the result\nfor scene in scenes:\n    print(scene['acquisition_date'].strftime('%Y-%m-%d'))\n    # Write scene footprints to disk\n    fname = f\"{scene['landsat_product_id']}.geojson\"\n    with open(fname, \"w\") as f:\n        json.dump(scene['spatial_coverage'].__geo_interface__, f)\n\napi.logout()\n```\n\nOutput:\n\n```\n4 scenes found.\n1995-09-23\n1995-08-22\n1995-08-15\n1995-06-28\n```\n\n#### Downloading scenes\n\n``` python\nfrom landsatxplore.earthexplorer import EarthExplorer\n\nee = EarthExplorer(username, password)\n\nee.download('LT51960471995178MPS00', output_dir='./data')\n\nee.logout()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyannforget%2Flandsatxplore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyannforget%2Flandsatxplore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyannforget%2Flandsatxplore/lists"}