I am able to open the file using /vsigs/ on-the-fly without downloading it but each time I use gdal.Translate, it takes a long time to extract a tile for each modification of projWin parameter. Any help or recommendation, please, to be able to extract tile quickly on-the-fly from GCS?

I am trying to do something similar to this How to efficiently access files with GDAL from an S3 bucket using VSIS3? but using GCS and followed by extracting a tile.

Note: I want to use gdal, not rasterio

  • Gdal.translate should know how to extract data from COG efficiently and it should not need to download the whole file. What makes you think that it does so? You can use gdal_translate executable for testing. Add --debug on to the command and it prints much information about what it is doing.
    – user30184
    Commented Jan 27, 2022 at 13:49
  • @user30184 I am testing it locally in a jupyter notebook and it takes a while (about 1:30 mins when working on a 600 MB COG). While reading from the local dir directly it does so fast. gdal.Translate('test.png', dem, projWin = (xmin, ymax, xmax, ymin), width=256, height = 256) Commented Jan 27, 2022 at 13:57
  • Then learn how to debug with your Python code. When data are in the cloud there will be a certain amount of http traffic because GDAL needs to read some bytes from the COG before it knows where to find the actual raster data. You should capture what http requests are sent and how fast the GCS responds. There may be some unnecessary calls which can be prevented with configuration options but if the main problem is slow network then they will not help.
    – user30184
    Commented Jan 27, 2022 at 14:12


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.