2

I would like to create a 3D buffer around powerlines inside a LAS file that contains forest and power lines in lidR (R package). If I would manually delineate the line features and export to an individual file,

How do I create a buffer around all points in that file?

I am thinking of something like this:

enter image description here

1 Answer 1

4

Assuming you have a shapefile with lines you can buffer the lines and clip the polygons

library(lidR)
library(sf)

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
ctg = readLAScatalog(LASfile)

# read a shapefile (here I'm making one manually)
m1 = matrix(c(684800, 685000, 5017800, 5018000), ncol = 2)
m2 = matrix(c(684900, 685000, 5017900, 5017900), ncol = 2)
powerline1 = st_linestring(m1)
powerline2 = st_linestring(m2)
powerlines = st_sfc(powerline1, powerline2)
powerlines = st_sf(powerlines)
st_crs(powerlines) = st_crs(ctg)

# Buffer the lines
buffer = st_buffer(powerlines, 10, endCapStyle = "SQUARE")

# Some plot
plot(ctg)
plot(powerlines, add = T)
plot(buffer, add = T, lty = 3, col = "NA")

# Extract the polygons and stream them into output files
opt_output_files(ctg) <- paste0(tempdir(), "/powerline_{ID}")
newctg = clip_roi(ctg, buffer)

# plot the new ctg
plot(newctg)

# The new file are in
newctg$filename
#> [1] "/tmp/Rtmp39NXdd/powerline_1.las" "/tmp/Rtmp39NXdd/powerline_2.las"
0

Your Answer

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

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