Use this in place of sf::st_layers(<one file>)$name, which cannot see a
split project at all. Reads each GeoPackage's registered tables rather than
trusting file names, so a file holding an unexpected table is still reported
honestly.
Arguments
- spec
A layout spec from
rfp_layout(). Not a path - a bare path would have to mean the project directory here, while everywhere else in rfp a bare GeoPackage path means the monolith layout at that file. Resolve it first.
Details
unique(x$file) is every rfp-managed GeoPackage in the project - what a
whole-file operation wants, whether that is a backup list, ogr2ogr or
VACUUM. One divergence to know about: a GeoPackage carrying no registered
table has no row here, so it is not listed.
Zero rows is the honest answer for a project with no layers yet. A caller
that requires some should say so itself with nrow(), rather than this
raising on its behalf.
Examples
project <- file.path(tempdir(), "layout_layers_example")
dir.create(project)
file.copy(
system.file("testdata", "subset_fixture", "parent",
"background_layers.gpkg", package = "rfp"),
project
)
#> [1] TRUE
layers <- rfp_layout_layers(rfp_layout(project))
layers$layer
#> [1] "lakes" "roads" "streams" "unused_sentinel"
unique(layers$file)
#> [1] "/tmp/RtmpfSNDuG/layout_layers_example/background_layers.gpkg"
unlink(project, recursive = TRUE)
