6

I am trying to read a Cloud Optimised GeoTiff (COG) from AWS S3. I can successfully run

gdalinfo /vsis3/cog-testing/HP_COG.tif

And see the details of the file and it says Layout: COG

But if I attempt to load the same file into QGIS 3.4 using the Data Source Manager, using the AWS S3 Protocol.

enter image description here

But when i try I get an error

Invalid Layer: GDAL provider Cannot open GDAL dataset /vsis3/cog-testing/HP_COG.tif: `/vsis3/cog-testing/HP_COG.tif' does not exist in the file system, and is not recognized as a supported dataset name. Raster layer Provider is not valid (provider: gdal, URI: /vsis3/cog-testing/HP_COG.tif

I am wondering if it is a region problem as my files are not the in the default region.

I have also tried using the standard HTTP protocol and also get an error.

Invalid Layer: GDAL provider Cannot open GDAL dataset /vsicurl/https://cog-testing.s3-eu-west-1.amazonaws.com/HP_COG.tif: `/vsicurl/https://cog-testing.s3-eu-west-1.amazonaws.com/HP_COG.tif' does not exist in the file system, and is not recognized as a supported dataset name. Raster layer Provider is not valid (provider: gdal, URI: /vsicurl/https://cog-testing.s3-eu-west-1.amazonaws.com/HP_COG.tif

And when I try the viscurl from my command prompt I get a 403 error.

gdalinfo /vsicurl/https://cog-testing.s3-eu-west-1.amazonaws.com/HP_COG.tif

Can anyone suggest what is going wrong?

3
  • Did you set the correct env variables (AWS_SECRET_ACCESS_KEY=VALUE AWS_ACCESS_KEY_ID=VALUE AWS_S3_ENDPOINT) Commented Nov 6, 2019 at 9:28
  • I have the same problem. I have a public image in my amazon s3 bucket and when I import it to QGIS using HTTPS protocol and its URI the image upload without problem, but if I try to do it with the AWS S3 protocol and the name of the bucket and the secret key, GDAL gives an error that cannot find the file
    – borjarf
    Commented Mar 4, 2020 at 8:34
  • @julsbreakdown how to do that? Where is the option in QGIS? Commented May 6, 2021 at 14:53

2 Answers 2

4

From the same Data Source Manager, in Raster tab, I have selected in the combobox : HTTP/HTTPS/FTP and as URI :

https://cog-testing.s3-eu-west-1.amazonaws.com/HP_COG.tif

And it works on QGIS 3.8.3 on Ubuntu 18.04 :

https raster file source

But I haven't an AWS SECRET KEY and can't investigate the AWS3 method.

2
  • I am using QGIS 3.4.10 and the HTTP/HTTPS/FTP fails as mentioned in my post. So what version are you using? I would expect the AWS to have optional AWS keys as some files can be public facing, like my file is
    – tjmgis
    Commented Sep 30, 2019 at 9:01
  • I've edited my post. Commented Sep 30, 2019 at 9:10
3

What normally works for me is:

  1. Verify you have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY set in either Project menu > Properties, Variables tab OR QGIS Settings, Variables tab. These values you get from AWS (See here or ask your administrator).

  2. To add a COG image, go to Layer Menu > Add Layer > Add Raster Layer. On the window that opens, select "Protocol..." under source type, "AWS S3" under "Type", and enter the bucket name and object key (without the bucket name)

    Meaning: s3://bucket-name/path/to/image_cog.tif goes to:

    • Bucket: bucket-name
    • Object Key: path/to/image_cog.tif

Like so: Example

That's it, you be able to view you image normally now

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.