1

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”

1 Answer 1

1

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.

1
  • that works thanks; the complete line would be: sf::st_write(sf::st_as_sf(ctg), "ctgIndex.shp")
    – Ray J
    Jul 6, 2023 at 19:17

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.