Retrieve and Process Vector Processing Unit (VPU) Hydrofabric Layers
This function retrieves and optionally filters spatial data layers from a GeoPackage (GPKG) based on a specified Vector Processing Unit ID (VPU ID). The function can either return the filtered layers as a list or write them to an output file.
Arguments
- gpkg
A string specifying the path to the GeoPackage file.
- vpuid
A vector of VPU IDs to filter the layers. If `NULL`, no filtering is applied. Default is `NULL`.
- outfile
A string specifying the path to write the filtered layers to a new GeoPackage. If `NULL`, the layers are returned as a list. Default is `NULL`.
Value
If `outfile` is `NULL`, returns a list where each element is a filtered spatial layer (`sf` object). If `outfile` is provided, returns the path to the output GeoPackage.
Details
The function reads all layers from the provided GeoPackage, excluding the "error" layer. For each layer, the data is optionally filtered by the provided `vpuid` and then processed into `sf` objects. If an output file path is provided, the filtered layers are written to a new GeoPackage. Otherwise, the layers are stored in a list and returned.