I am attempting to loop over dozen of https S3-hosted COPC (LAZ) files in Python for QGIS to (1) render them, and (2) write out a simple thumbnail Jpeg. Using the script below I can successfully loop over downloaded local COPC files, but I can't figure out how to load https S3-hosted COPC (LAZ) files into QGIS.

At line 16, next, QgsPointCloudLayer call either faults or crashes QGIS using an https address. (again this works with local files).

pLayer = QgsPointCloudLayer(urlLOLA, nameCOPC, "pdal", pLayerOptions)

Here is the full code block, but really figuring out how to load a COPC/LAZ file from an https address using QgsPointCloudLayer should the key. All the image writing is just extra here.

EDIT: updated code below to replace "pdal" with "copc" and added pause function to allow time for the streamed file to load and render.

from qgis.core import *
import time

def pause(seconds):
    print("Paused for " + str(seconds) + " seconds to allow load")
    time_end = time.time() + seconds
    while time.time() < time_end:

#S3 URL (now works also!)

#local files (works)
#      "/tmp/LolaRDR_15N30N_285E300E.copc.laz"]

canvas = iface.mapCanvas()
for urlLOLA in files:
    nameJPEG="/tmp/" + nameCOPC.replace(".copc.laz","_thumb.jpg")

    pLayer = QgsPointCloudLayer(urlLOLA, nameCOPC, "copc")

    if pLayer.isValid():
        print(nameCOPC + ": " + str(pLayer.pointCount()))

        #Grab newly added layer and set to 70% transparent
        layer = iface.activeLayer()

        #zoom to layer and refresh
        extent = layer.extent()
        #force 60-second pause to allow streamed COPC to load and render

        #export Jpeg
        print("created file: " + nameJPEG)            
        #remove layer
        QgsProject.instance().removeMapLayer( layer.id() )
  • with the addition of the pause function, likely QgsApplication.processEvents(), there are some stability issues for QGIS. Not sure what is going on (memory leak?). In the end, I used downloaded local files, not streamed files.
    – Trent
    Sep 12 at 21:00

1 Answer 1


Change the provider from "pdal" to "copc"

With this code:

from qgis.core import *


canvas = iface.mapCanvas()
for urlLOLA in files:
    pLayer = QgsPointCloudLayer(urlLOLA, nameCOPC, "copc")

    if pLayer.isValid():


enter image description here

enter image description here

  • Brilliant - sure enough the update from from "pdal" to "copc" worked. Now since the COPC files are streamed, I had to add a delay into the script to allow the file to fully load and render before saving an image. Using canvas.waitWhileRendering() wasn't enough since the file still wasn't fully loaded. I added a "pause" timer function to the code above to help with that issue.
    – Trent
    Sep 9 at 17:55

Your Answer

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

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