Closed merretbuurman closed 4 months ago
TODO: Check if we can prevent the behaviour. - Just add the file to Nimbus? TODO: My solution may fail if the text is returned in another language than English. Maybe need to specify the locale.
I added the download link for the file on Nimbus, so that works now.
If Nimbus is available, it downloads and uses it:
>
> get_regional_unit_id(df, "lon", "lat")
Downloading the global regional unit file to /tmp/RtmpOZY0OU/regional_unit_ovr.tif...
trying URL 'https://public.igb-berlin.de/index.php/s/agciopgzXjWswF4/download?path=%2Fglobal&files=regional_unit_ovr.tif'
Content type 'image/tiff' length 123262363 bytes (117.6 MB)
==================================================
downloaded 117.6 MB
[1] 58
>
If Nimbus is not available, it will try the GDrive URL and likely fail, but then the user gets a hint on how to manually fix:
>
> get_regional_unit_id(df, "lon", "lat")
Downloading the global regional unit file to /tmp/RtmpOZY0OU/regional_unit_ovr.tif...
trying URL 'https://pppublic.igb-berlin.de/index.php/s/agciopgzXjWswF4/download?path=%2Fglobal&files=regional_unit_ovr.tif'
Download failed, reason: URL 'https://pppublic.igb-berlin.de/index.php/s/agciopgzXjWswF4/download?path=%2Fglobal&files=regional_unit_ovr.tif': status was 'Couldn't resolve host name'
trying URL 'https://drive.google.com/uc?export=download&id=1ykV0jRCglz-_fdc4CJDMZC87VMsxzXE4&confirm=t'
Content type 'text/html; charset=utf-8' length 2433 bytes
==================================================
downloaded 2433 bytes
The file /tmp/RtmpOZY0OU/regional_unit_ovr.tif is only 2433 bytes, maybe the download went wrong.
The file /tmp/RtmpOZY0OU/regional_unit_ovr.tif contains text asking you whether to download, so the download definitely went wrong.
Error in get_regional_unit_id(df, "lon", "lat") :
Downloading the file "regional_unit_ovr.tif" went wrong, as you manually need to confirm skipping the virus check.
Please download manually at https://drive.google.com/uc?export=download&id=1ykV0jRCglz-_fdc4CJDMZC87VMsxzXE4&confirm=t and store to /tmp/RtmpOZY0OU/regional_unit_ovr.tif . Stopping.
>
The code is now here: https://github.com/merretbuurman/hydrographr/tree/dev_get_regional_unit_id_fix_download_bug
Once I have tested and linted it all properly, I will merge it to main.
This was already merged into main, see commit https://github.com/merretbuurman/hydrographr/commit/aa7fb4b40c45ba54cbbfa57667e70d6dec86f9e2 from 5 March.
When using the
get_regional_unit_id()
function, the function did not download theregional_unit_ovr.tif
file directly, instead it downloaded a HTML file with this question:Google Drive can't scan this file for viruses. regional_unit_ovr.tif (118M) is too large for Google to scan for viruses. Would you still like to download this file?
(in German:
Google Drive kann keinen Virenscan für diese Datei durchführen. regional_unit_ovr.tif (118M) ist zu groß und kann von Google nicht auf Viren geprüft werden. Möchten Sie die Datei trotzdem herunterladen?
)So the function fails with the error
ERROR 4: '/tmp/Rtmp8KQI/regional_unit_ovr.tif' not recognized as a supported file format
.I have not checked to prevent this, but I added a check to the function and instructions to download the file manually and placing it into the right directory (this branch here: https://github.com/merretbuurman/hydrographr/tree/dev_sugar_regional_unit_id ). I'll push or make a PR as soon as I have figured out how to build.
Details of the returned file: