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

Warn user when request exceeds maximum download size from Opentopography #16

Open
mdpiper opened this issue Oct 1, 2021 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@mdpiper
Copy link
Member

mdpiper commented Oct 1, 2021

OpenTopography has a ceiling on the size of a data request--see #15 for an example. The Topography data component should warn a user when an instance is created that would request an area exceeding this threshold.

@mdpiper
Copy link
Member Author

mdpiper commented Oct 1, 2021

@mdpiper mdpiper added the enhancement New feature or request label Oct 1, 2021
@mdpiper
Copy link
Member Author

mdpiper commented Oct 1, 2021

Fixing this will address #15.

@mdpiper
Copy link
Member Author

mdpiper commented Mar 22, 2022

The max download size is product-dependent. From OT:

Note: Requests are limited to 125,000,000 km2 for SRTM15+ V2.1, 4,050,000 km2 for SRTM GL3, COP90 and 450,000 km2 for all other data.

@Witold1
Copy link

Witold1 commented Jan 14, 2024

Affected line(s):

response = requests.get(Topography.data_url(), params=params, stream=True)
if response.status_code == 401:
if self._api_key.source == "demo":
msg = os.linesep.join(
"It looks like you are using a demo key. This error may be the result of "
"you reaching your maximum number of downloads."
)
else:
msg = (
"It looks like you are using a user-supplied key. This error may mean "
"that your key is out of date or there is a typo in the supplied key. "
f"(source={self._api_key.source})"
)
response.reason = os.linesep.join([response.reason, "", msg, ""])
response.raise_for_status()

Reproduce size related error (example - app. Romania [RO] bbox):

# Romania bbox
params = Topography.DEFAULT.copy()
params["south"] = 30
params["north"] = 50
params["west"] = 20
params["east"] = 30
params["dem_type"] = "COP30"

boulder = Topography(**params)
boulder.fetch()

> HTTPError: 400 Client Error: 400 for url: https://portal.opentopography.org/API/globaldem?demtype=COP30&south=30&north=50&west=20&east=30&outputFormat=GTiff&API_Key=demoapikeyot2022

Simplified reproduction (requests, link):

import requests

LINK = "https://portal.opentopography.org/API/globaldem?demtype=COP30&south=30&north=50&west=20&east=30&outputFormat=GTiff&API_Key=demoapikeyot2022"

requests.get(LINK).status_code
> 400
requests.get(LINK).text
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?><error>Error: The maximum area for COP30 is 450,000 km2. The selected area is 1,885,504 km2.</error>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants