R LidR Export – How to Export a lidR LAScatalog to a Shapefile

lidrr

I would like to export a lascatalog to a shapefile. It could be done in the past with rgdal but this is being retired.

The error is below.

library(lidR)
library(sf)
ctg <- readLAScatalog(system.file("extdata", "MixedConifer.laz", package="lidR"))
st_write(as(ctg, "sf"), "ctgIndex.shp")
#> Error in as(ctg, "sf") : 
#>  no method or default for coercing “LAScatalog” to “sf”

Best Answer

Use sf::st_as_sf instead of as(ctg, "sf") before to write with sf::st_write

Note: sf::st_as_sf simply returns ctg@data which IS an sf object.

Related Question