Configure S3 for COPC

Disclaimer: I'm pretty basic as far as security/AWS devops goes, so you should consider this a way to host cloud optimized point cloud files, definitely not the way.

First off, I highly recommend Bert Temme's excellent blog post about creating cloud optimized point cloud (COPC) files using PDAL (version 2.4+ to take advantage of COPC reader/writer).

This blog post explains how I created a COPC from LiDAR BC, configured AWS S3 for storage/hosting, and displayed the file on the COPC Viewer.

Get the data

I downloaded LAZ data from LiDAR BC. It's a nice, basic GUI for data download. Find the tile, download the data. In my case, I downloaded a 177 MB LAZ file.

LiDAR BC Download

Convert LAZ to COPC

I converted my LAZ file to COPC with the following PDAL Python script:

import pdal

json = """
[
    {
        "type":"readers.las",
        "filename":"/path/to/input.laz"
    },
    {
        "type":"writers.copc",
        "filename":"/path/to/output.copc.laz"
    }
]
"""

pipeline = pdal.Pipeline(json)
pipeline.execute()

The resulting file ballooned somewhat to 499 MB, but hey, it's cloud optimized.

Upload to AWS S3 and Configure for Display

You can use whatever hosting or cloudprovider you like, but this is how I set up AWS S3.

First step, upload.

Second step, configure CORS. I will explain CORS in a future blog post1, but suffice it to say that by configuring CORS on the S3 bucket, we can restrict the methods allowed to interact with files (in this case, GET) and the domains from which they can originate (in this case, https://viewer.copc.io). The CORS configuration I added to my S3 bucket, under the Permissions tab, was:

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET"
        ],
        "AllowedOrigins": [
            "https://viewer.copc.io"
        ],
        "ExposeHeaders": [
            "x-amz-server-side-encryption",
            "x-amz-request-id",
            "x-amz-id-2"
        ],
        "MaxAgeSeconds": 300
    }
]

Generate a Presigned URL

S3 Presigned URLs are magical things that allow you to temporarily attach your own permissions to an S3 URL, so someone else can do something with a file. In this case, I want a viewer to be able to download chunks of a point cloud by pointing it to a URL, but I don't want to make my file completely public for anyone to download, and I don't want to set up authorization between the viewer and my file. I get the added peace of mind that the url will expire in a certain amount of time, so absolutely no one will be able to use the URL later. Generate a presigned URL in your preferred method (CLI or GUI).

View the COPC

Hobu has kindly provided a COPC viewer here. The UX is about as straighforward as possible: paste your presigned URL where it says "Add a Point Cloud". In the process of making the animation below, I downloaded approximately 250 MB through the browser.

LiDAR BC Download

That is all. As always get in touch with me on Twitter if you want to talk more about this! I'd be very interested to know better strategies for configuring S3 for hosting/serving files like this, or if there are other ways to further optimize COPCs.s

1: I will never explain CORS. You can Google it, though.