Extract Layer Information from QGIS Project
Source:R/ngr_spk_q_layer_info.R
ngr_spk_q_layer_info.RdReads a QGIS project file (.qgs or .qgz) and extracts layer metadata, including menu name, provider, data source, and layer name.
Usage
ngr_spk_q_layer_info(path, attrs = c("id", "name", "source", "providerKey"))Value
A tibble::tibble with one row per layer, including extracted attributes, plus computed layer_name and time_exported, sorted alphabetically by name.
Details
If the input is a .qgz file, it will be unzipped to extract the internal project.qgs. The function then parses the XML structure of the project to extract layer information from <layer-tree-layer> nodes.
Returned columns include:
name_menu: layer name as displayed in the QGIS menuprovider: data provider key (e.g.,ogr,gdal)source: absolute or relative path to the data sourcelayer_name: the internal layer name stringid: QGIS-assigned layer idtime_exported: timestamp in formatyyyymmdd hh::mmwhen the function was run
Examples
if (FALSE) { # \dontrun{
res <- ngr_spk_q_layer_info(
"~/Projects/gis/ng_koot_west_2023/ng_koot_west_2023.qgs",
attrs = c("id", "name", "source", "providerKey")
)
} # }