I am using osgeo.gdal.translate
function in Python to download multiple tif files from a browser (FAO Data File Explorer), what requires to specify the word /vsicurl/ before the url name.
The files are accessed successfully within a loop, but… I don’t know where they are stored, or the way I can accesed to them. I need them locally in my machine.
Does anybody know how to access them or download to a local folder?
I am using this google colab code for downloading the data.
This are the steps given to download the data:
from osgeo import gdal # The most important one, gdal downloads the data.
import pandas as pd # Pandas helps to deal with calendar related things.
from tqdm.notebook import tqdm # We use tqdm to show a simple progress bar.
Then we define the spatial domain. Choose a bounding box for which to download data.
bb = [15, -26, 22, -36] # [xmin, ymax, xmax, ymin]
We set some variables required by gdal.Translate.
options = gdal.TranslateOptions(
projWin = bb, # passing the bounding-box to gdal.Translate
creationOptions = ["COMPRESS=DEFLATE"], # reduces the filesize of the created files.
Daily
Choose for which dates to download daily data.
dates = pd.date_range("2018-01-01", "2018-12-01")
Next, for each date we define a unique filename and the precise url, then we download the data. The ‘/vsicurl/’ part of url is something only required by gdal.Translate, in your browser you can remove that part of the url.
Loop over each date
in dates
.
for date in tqdm(dates):
# Define unique filename.
filename = f"AGERA5_ET0_{date.strftime('%Y%m%d')}.tif"
# Define the exact url for this date.
url = f"/vsicurl/https://data.apps.fao.org/static/data/c3s/AGERA5_ET0/{filename}"
# Download the actual data.
ds = gdal.Translate(filename, url, options = options)