I am attempting to load a Cloud Optimized GeoTIFF (COG) via Python in QGIS 3.4.7. Specifically, I can manually load a COG using the tutorial posted here.
The URL for the COG is: http://oin-hotosm.s3.amazonaws.com/59d33df023c8440011d7b26d/0/b378087a-c2a5-43a0-abec-71fcfb051150.tif
I have tried using the AddRasterLayer approach:
path = "http://oin-hotosm.s3.amazonaws.com/59d33df023c8440011d7b26d/0/b378087a-c2a5-43a0-abec-71fcfb051150.tif"
self.iface.addRasterLayer(path, 'name')
and as a URI:
uri = QgsDataSourceUri()
uri.setParam('url', path)
uri.setParam("identifier", path)
rlayer = QgsRasterLayer(str(uri.encodedUri()), 'my cog layer')
QgsProject.instance().addMapLayer(rlayer)
As far as I understand, GDAL should be loading these under the hood. In the case of the former, I am seeing:
2020-08-26T22:35:45 CRITICAL Invalid Layer : GDAL provider Cannot open GDAL dataset http://oin-hotosm.s3.amazonaws.com/59d33df023c8440011d7b26d/0/b378087a-c2a5-43a0-abec-71fcfb051150.tif:
An error occurred while creating a virtual connection to the DAP server:Error while reading the URL: http://oin-hotosm.s3.amazonaws.com/59d33df023c8440011d7b26d/0/b378087a-c2a5-43a0-abec-71fcfb051150.tif.ver.
The OPeNDAP server returned the following message:
Not Found: The data source or server could not be found.
Often this means that the OPeNDAP server is missing or needs attention;
Please contact the server administrator.
Raster layer Provider is not valid (provider: gdal, URI: http://oin-hotosm.s3.amazonaws.com/59d33df023c8440011d7b26d/0/b378087a-c2a5-43a0-abec-71fcfb051150.tif
In the case of the latter it fails silently.
How does one load a COG into QGIS using the Python bindings?