Closed ratnanil closed 3 months ago
I would like to be able to coerce the output of st_layers to a data.frame. Currently, I do the following, which seems wrong.
st_layers
suppressPackageStartupMessages(library(sf)) as.data.frame.sf_layers <- \(x) sf:::print.sf_layers(x) |> data.frame() layers <- st_layers(system.file("sqlite/test3.sqlite",package="sf")) layers_df <- as.data.frame(layers) # I dont know how to supress print-ing here #> Driver: SQLite #> Available layers: #> layer_name geometry_type features fields crs_name #> 1 Towns Point 8101 5 WGS 84 / UTM zone 32N #> 2 HighWays Line String 10 2 WGS 84 / UTM zone 32N #> 3 Regions Multi Polygon 10 2 WGS 84 / UTM zone 32N
class(layers_df) #> [1] "data.frame"
Would it not make sense to have something similar implemented in sf?
sf
I think we already have that; did you check the dev version of sf? See https://github.com/r-spatial/sf/blob/main/NEWS.md
Ah beautiful, thanks!
I would like to be able to coerce the output of
st_layers
to a data.frame. Currently, I do the following, which seems wrong.Would it not make sense to have something similar implemented in
sf
?