|
1 | 1 | """
|
2 |
| -Get, read, and parse data from |
| 2 | +Get, read, and parse data from |
3 | 3 | `CGIAR GeoPortal <https://srtm.csi.cgiar.org/>`_.
|
4 | 4 |
|
5 | 5 | For more information, see the following links:
|
@@ -43,7 +43,7 @@ def _lat_lon_to_query(longitude, latitude, srtm_arc_sec=3):
|
43 | 43 | raise Exception("Please use SRTM 1 Arc Second or SRTM 3 Arc Second")
|
44 | 44 |
|
45 | 45 |
|
46 |
| -def download_SRTM(latitude, longitude, srtm_arc_sec=3, |
| 46 | +def download_SRTM(latitude, longitude, srtm_arc_sec=3, |
47 | 47 | path_to_save="./", proxies=None):
|
48 | 48 | r'''Downloads a SRTM DEM tile from CGIAR,
|
49 | 49 | saves it to a path, and loads it as an array
|
@@ -71,14 +71,15 @@ def download_SRTM(latitude, longitude, srtm_arc_sec=3,
|
71 | 71 | '''
|
72 | 72 | import skimage
|
73 | 73 | long, lat = _lat_lon_to_query(longitude, latitude, srtm_arc_sec)
|
74 |
| - base_url = 'https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/' |
| 74 | + org_url = 'https://srtm.csi.cgiar.org/' |
| 75 | + base_url = org_url + 'wp-content/uploads/files/srtm_5x5/TIFF/' |
75 | 76 | query_URL = base_url + f'srtm_{ long:02d }_{ lat:02d }.zip'
|
76 | 77 | res = requests.get(query_URL, proxies=proxies, verify=False)
|
77 | 78 | res.raise_for_status()
|
78 | 79 | zipfile = ZipFile(io.BytesIO(res.content))
|
79 | 80 | ext = '.tif'
|
80 | 81 | files = zipfile.namelist()
|
81 |
| - file = [f for f in files if ext in f][0] |
| 82 | + file = [ f for f in files if ext in f ][0] |
82 | 83 | path= zipfile.extract(file, path=path_to_save)
|
83 | 84 | img = skimage.io.imread(path)
|
84 | 85 | return img, path
|
0 commit comments