CNES / MAJA

Level-2A processor used for atmospheric correction and cloud-detection. The active repository is the one below, this one is kept to leave access to the older issues.
https://gitlab.orfeo-toolbox.org/maja/maja
Apache License 2.0
139 stars 25 forks source link

[ENH] If SRTM file is not present, try to download it. #10

Closed Julien-Osman closed 5 years ago

Julien-Osman commented 5 years ago

This PR addresses an issue with prepare_dtm. Indeed, with the current version of prepare_dtm, if a SRTM file is not found, the program stops. This is fine when working with one product/tile, but when someone wants to run a script that calls prepare_dtm over a large number of products/tiles it becomes a problem. The solution I propose is to download the missing SRTM files directly from the CGIAR website. Then, the program stops only if the file can't be download.

Julien-Osman commented 5 years ago

It appears that urllib.request.urlretrieve is legacy, so it might become deprecated at some point. Moreover, it is not compatible with python2. A solution to both those issues is to use the request module, but it would add a dependency. What do you prefer ?

petket-5 commented 5 years ago

Hi Julien,

Thanks for the addition. I propose to solve it using a simple try-except block around the import:

try:
   from urllib.request import urlretrieve
except:
   from urllib import urlretrieve

This is not beautiful, but at least this will add backwards-compatibility to python2.

Peter