Convert .laz to .copc.laz using pdal library, following the workflow in this blog post, although in the blog post they convert from the native projection to web mercator before converting to COPC. It's not necessary to reproject the data. So we just use one pipeline to convert the original .laz to COPC.
import pdal
import fsspec
fs_read = fsspec.filesystem('s3', anon=True)
url = 's3://cmgp-sfm-public-read-bucket/RSCC_EventResponse_Jan2023/20230105_MB_SC_Cap_UltraHi_NAD83_2011_UTM10N_ConfWater_Trimmed.laz'
fs_read.info(url)
{'ETag': '"9787cc8cdd4fcea93c73de5ce2e89b80-332"', 'LastModified': datetime.datetime(2023, 1, 9, 22, 14, 5, tzinfo=tzutc()), 'size': 2784154775, 'name': 'cmgp-sfm-public-read-bucket/RSCC_EventResponse_Jan2023/20230105_MB_SC_Cap_UltraHi_NAD83_2011_UTM10N_ConfWater_Trimmed.laz', 'type': 'file', 'StorageClass': 'STANDARD', 'VersionId': None, 'ContentType': 'binary/octet-stream'}
#fs_read.ls('s3://cmgp-sfm-public-read-bucket/RSCC_EventResponse_Jan2023/LAZ_for_Release_2023_1_11/') # bucket doesn't allow anon listing
from pathlib import Path
p = Path(url)
local_laz_file = f'{p.stem}.laz'
local_laz_file
'20230105_MB_SC_Cap_UltraHi_NAD83_2011_UTM10N_ConfWater_Trimmed.laz'
fs_local = fsspec.filesystem('file')
if not fs_local.exists(local_laz_file):
fs_read.download(url, local_laz_file)
local_copc_file = f"{p.stem}.6339.copc.laz"
write_copc_pipeline = [
{
"type":"readers.las",
"filename":local_laz_file
},
{
"type":"writers.copc",
"filename":local_copc_file
}
]
write_copc_pipeline = str(write_copc_pipeline).replace("'", '"')
pipeline = pdal.Pipeline(write_copc_pipeline)
count = pipeline.execute()
fs_write = fsspec.filesystem('s3', profile='esip-qhub')
s3_copc_file = f's3://esip-qhub-public/testing/{local_copc_file}'
_ = fs_write.upload(local_copc_file, s3_copc_file)
fs_read.info(s3_copc_file)
{'ETag': '"1018c2cfec1dff7d3ba5ebc3e2f5bbb3-56"', 'LastModified': datetime.datetime(2023, 1, 12, 16, 14, 43, tzinfo=tzutc()), 'size': 2914701303, 'name': 'esip-qhub-public/testing/20230105_MB_SC_Cap_UltraHi_NAD83_2011_UTM10N_ConfWater_Trimmed.6339.copc.laz', 'type': 'file', 'StorageClass': 'STANDARD', 'VersionId': None, 'ContentType': 'binary/octet-stream'}
viewer_url = f'https://viewer.copc.io/?copc=https://esip-qhub-public.s3.amazonaws.com/testing/{local_copc_file}'
print(viewer_url)
https://viewer.copc.io/?copc=https://esip-qhub-public.s3.amazonaws.com/testing/20230105_MB_SC_Cap_UltraHi_NAD83_2011_UTM10N_ConfWater_Trimmed.6339.copc.laz
This notebook was run on the ESIP Nebari deployment (JupyterHub on Kubernetes) at https://nebari.esipfed.org, using the 32GB server type (it exceeded memory with the 8GB or 16GB server types). We used this conda environment:
name: pdal
channels:
- conda-forge
dependencies:
- python=3.10
- pdal
- python-pdal
- fsspec
- s3fs
- ipykernel