-
-
Save RichardScottOZ/a7f32a7ad5f6f5fe3b9358c7f4fab428 to your computer and use it in GitHub Desktop.
Find all the possible ESRI Land Cover scene and put them in a big list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.9.5" | |
}, | |
"orig_nbformat": 4, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3.9.5 64-bit" | |
}, | |
"interpreter": { | |
"hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2, | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# https://soilspackage-useast.s3.amazonaws.com/EsriLandCover/25C_20200101-20210101.tif\n", | |
"\n", | |
"# https://soilspackage-useast.s3.amazonaws.com/EsriLandCover/56X_20200101-20210101.tif\n", | |
"# https://soilspackage-useast.s3.amazonaws.com/EsriLandCover/25S_20200101-20210101.tif\n", | |
"# https://soilspackage-useast.s3.amazonaws.com/EsriLandCover/20S_20200101-20210101.tif\n", | |
"# https://soilspackage-useast.s3.amazonaws.com/EsriLandCover/14Q_20200101-20210101.tif\n", | |
"\n", | |
"# C-X\n", | |
"# 01-60" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import requests\n", | |
"import string\n", | |
"import concurrent.futures\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 28, | |
"metadata": { | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"base_url = \"https://soilspackage-useast.s3.amazonaws.com/EsriLandCover/{id}_20200101-20210101.tif\"\n", | |
"\n", | |
"def uri_exists_stream(id: str) -> bool:\n", | |
" uri = base_url.format(id=id)\n", | |
" try:\n", | |
" with requests.get(uri, stream=True) as response:\n", | |
" try:\n", | |
" response.raise_for_status()\n", | |
" return uri\n", | |
" except requests.exceptions.HTTPError:\n", | |
" return None\n", | |
" except requests.exceptions.ConnectionError:\n", | |
" return False\n", | |
"\n", | |
"rows = list(string.ascii_uppercase)\n", | |
"cols = range(1,61)\n", | |
"\n", | |
"ids = [f\"{col:02}{row}\" for col in cols for row in rows]\n", | |
"\n", | |
"with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor:\n", | |
" results = executor.map(uri_exists_stream, ids)\n", | |
"\n", | |
"all_results = [r for r in results if r is not None]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 33, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"with open('tiles-list.txt', 'w') as f:\n", | |
" f.writelines('\\n'.join(all_results) + '\\n')" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment