Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fix to prevent errors when downloading Landsat 8 Collection 2. … #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions landsatxplore/earthexplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
"sentinel_2a": "5e83a42c6eba8084",
}

# Quick fix to use fallback paths for Landsat 8 errors (suggested at https://github.com/yannforget/landsatxplore/issues/45)
DATA_PRODUCTS_II = {
"landsat_tm_c1": "5e83d08fd9932768",
"landsat_etm_c1": "5e83a507d6aaa3db",
"landsat_8_c1": "5e83d0b84df8d8c2",
"landsat_tm_c2_l1": "5e83d0a0f94d7d8d",
"landsat_etm_c2_l1": "5e83d0d08fec8a66",
"landsat_ot_c2_l1": "5e81f14f92acf9ef",
"landsat_tm_c2_l2": "5e83d11933473426",
"landsat_etm_c2_l2": "5e83d12aed0efa58",
"landsat_ot_c2_l2": "5e83d14fec7cae84",
"sentinel_2a": "5e83a42c6eba8084",
}

def _get_tokens(body):
"""Get `csrf_token` and `__ncforminfo`."""
Expand Down Expand Up @@ -144,8 +157,16 @@ def download(self, identifier, output_dir, dataset=None, timeout=300, skip=False
entity_id = self.api.get_entity_id(identifier, dataset)
else:
entity_id = identifier
url = EE_DOWNLOAD_URL.format(
data_product_id=DATA_PRODUCTS[dataset], entity_id=entity_id
)
filename = self._download(url, output_dir, timeout=timeout, skip=skip)

# Quick fix to use fallback paths for Landsat 8 errors (suggested at https://github.com/yannforget/landsatxplore/issues/45)
try:
url = EE_DOWNLOAD_URL.format(
data_product_id=DATA_PRODUCTS[dataset], entity_id=entity_id
)
filename = self._download(url, output_dir, timeout=timeout, skip=skip)
except:
url = EE_DOWNLOAD_URL.format(
data_product_id=DATA_PRODUCTS_II[dataset], entity_id=entity_id
)
filename = self._download(url, output_dir, timeout=timeout, skip=skip)
return filename