# NOT RUN {
LASfile <- system.file("extdata", "example.laz", package="rlas")
las <- readLAS(LASfile)
# By default the sensor and spatial index codes are 0
sensor(las)
index(las)
# Codes are used internally and not intended to be known by users
# Use h option for human readable output
sensor(las, h = TRUE)
index(las, h = TRUE)
# Modification of the sensor enables users to select a better spatial index
# when processing the point-cloud.
sensor(las) <- "tls"
sensor(las, h = TRUE)
index(las, h = TRUE)
# Modification of the spatial index forces users to choose one of the available
# spatial indexes.
index(las) <- "quadtree"
sensor(las, h = TRUE)
index(las, h = TRUE)
# The simplest way to take advantage of appropriate spatial indexing is
# to use one of the read*LAS() functions.
las <- readTLSLAS(LASfile)
sensor(las, h = TRUE)
index(las, h = TRUE)
# But for some specific point-clouds / algorithms it might be advisable to force
# the use of a specific spatial index to perform the computation faster
index(las) <- "voxelpartition"
index(las, h = TRUE)
# With a LAScatalog, spatial indexing information is propagated to the
# different chunks
ctg = readTLSLAScatalog(LASfile)
index(ctg) <- "voxelpartition"
sensor(ctg, h = TRUE)
index(ctg, h = TRUE)
# ==================
# PERFORMANCE TESTS
# ==================
# }
# NOT RUN {
# Performance tests on TLS
# ------------------------
# The package does not include TLS data
# so we can generate something that looks TLS-ish
# >>>>>>>>>>>
X = runif(50, -25, 25)
Y = runif(50, -25, 25)
X = as.numeric(sapply(X, function(x) rnorm(2000, x, 2)))
Y = as.numeric(sapply(Y, function(x) rnorm(2000, x, 2)))
Z = abs(rnorm(length(Y), 10, 5))
veg = data.frame(X,Y,Z)
X = runif(5000, -30, 30)
Y = runif(5000, -30, 30)
Z = runif(5000, 0, 1)
ground = data.frame(X,Y,Z)
X = runif(30, -30, 30)
Y = runif(30, -30, 30)
Z = runif(30, 0, 30)
noise = data.frame(X,Y,Z)
las = LAS(rbind(ground, veg, noise))
# <<<<<<<<<<<<<
plot(las)
# If read with readALSLAS()
sensor(las) <- "als"
system.time(classify_noise(las, sor(20, 8)))
#> 1.5 sec
# If read with readTLSLAS()
sensor(las) <- "tls"
system.time(classify_noise(las, sor(20, 8)))
#> 0.6 sec
# Performance tests on ALS
# ------------------------
# The package does not include large ALS data
# so we can generate something that looks ALS-ish
# >>>>>>>>>>>
X = runif(4e5, 0, 1000)
Y = runif(4e5, 0, 1000)
Z = 40*sin(0.01*X) + 50*cos(0.005*Y) + abs(rnorm(length(Y), 10, 5))
veg = data.frame(X,Y,Z)
X = runif(100, 0, 1000)
Y = runif(100, 0, 1000)
Z = 40*sin(0.01*X) + 50*cos(0.005*Y) + abs(rnorm(length(Y), 10, 5)) + runif(100, 30, 70)
noise = data.frame(X,Y,Z)
las = LAS(rbind(veg, noise))
# <<<<<<<<<<<<<
plot(las)
# If read with readALSLAS()
sensor(las) <- "als"
system.time(classify_noise(las, sor(15, 8)))
#> 3 sec
# If read with readTLSLAS()
sensor(las) <- "tls"
system.time(classify_noise(las, sor(15, 8)))
#> 4.3 sec
# }
Run the code above in your browser using DataLab