copc4R
March 14, 2026 · View on GitHub
R package for reading and writing Cloud Optimized Point Cloud (COPC) files from local disk or HTTP(S) endpoints using range reads. Supports spatial queries, multi-resolution sampling, streaming iteration, deterministic tiling, and lidR catalog integration.
It enables R users to read .copc.laz binary files — a single-file, spatially indexed variant of LAZ commonly used for streaming LiDAR data from the cloud.
Installation
# Install the development version from GitHub:
# install.packages("remotes")
remotes::install_github("bi0m3trics/copc4R")
Quick example
library(sf)
library(copc4R)
# ── Define a point location and buffer to a 100 m circular AOI ───────────────
sf_use_s2(TRUE) # st_buffer unit is meters for geographic CRS
aoi <- st_sf(
id = 1,
geometry = st_sfc(st_point(c(-111.72671, 35.10700)), crs = 4326)
)
aoi <- st_buffer(aoi, dist = 100)
# ── Stream points from USGS 3DEP via Planetary Computer STAC ─────────────────
# read_copc() detects the STAC endpoint, discovers intersecting tiles,
# fetches only the octree nodes overlapping the AOI via HTTP range reads,
# clips to the circle boundary, and merges results across tile boundaries.
# The "3dep-lidar-copc" collection is selected automatically for this host.
result <- read_copc(
"https://planetarycomputer.microsoft.com/api/stac/v1/search",
aoi = aoi,
select = "xyzicrnap", # X Y Z Intensity Classification ReturnNumber
# NumberOfReturns ScanAngle PointSourceID
filter = paste(
"-drop_withheld", # remove withheld flag points
"-keep_voxel 1.0", # 3-D voxel thinning at ~1 m spacing
"-keep_first", # first returns only
"-drop_noise" # drop ASPRS noise classes (7, 18)
),
progress = TRUE
)
# result$data -- data.table of point attributes
# result$header -- named list of LAS header fields
# ── Convert to a lidR LAS object and visualise ───────────────────────────────
las <- as_las(result)
lidR::plot(las)
Features
- Reads
.copc.lazfiles from local paths or HTTP(S) URLs via range reads — only the bytes you need are fetched. - Spatial filtering: bounding box, polygon AOI, corridor, and Z-range queries through the COPC octree hierarchy.
- Attribute filters: pass lidR/LAStools-style filter strings (e.g.
-keep_first,-drop_noise,-keep_voxel). - Multi-resolution LOD sampling for fast previews without reading the full point cloud.
- Deterministic tiling for reproducible, grid-based point cloud partitioning.
- Streaming iterators for memory-efficient processing of large files.
- lidR catalog integration via
read_copc_catalog()andcopc_apply(). - STAC / Planetary Computer support — auto-discovers intersecting COPC tiles from a STAC endpoint.
- Writes
.copc.lazfiles viawrite_copc(). - Returns
data.tableoutput with rlas-compatible header conventions. - Column selection via a lidR-style
selectstring ("xyz","xyzirc","*", etc.). - Optional conversion to
lidR::LASobjects viaas_las(). - Bundled
LASzipfor LAZ decompression — no external system dependencies required.
Copyright Information
copc4R contains code written by Andrew Sánchez Meador as well as third-party code included for technical reasons. Details below.
- For
LASzip:- (c) 2007-2021 martin.isenburg@rapidlasso.com - http://rapidlasso.com
- Provided under GPL-3 license.
- For
rlascode conventions enabling Martin Isenburg's code to be wrapped into R:- (c) 2016-2021 Jean-Romain Roussel
- Provided under GPL-3 license.
- For the COPC specification:
- (c) 2021 Andrew Bell, Howard Butler, and Connor Manning of Hobu, Inc.
- Provided under MIT license.
- https://github.com/copcio/copcio.github.io/tree/main
- For
copc4RR code:- (c) 2025-2026 Andrew Sánchez Meador
- Provided under MIT license.