Interface to the QGIS Project
QgisProject.RdThe QgisProject class provides an R6 interface to interact with the
currently active QGIS project. It allows reading project properties, listing
layers, and transferring spatial data between R and QGIS.
Details
Please note that you should not instantiate this class manually using
QgisProject$new(). Instead, use the public wrapper function
qgis_project() to safely establish the connection.
Active bindings
title(character) The title of the QGIS project (read-only).
path(character) The absolute path to the QGIS project file (read-only).
crs(character) The authority ID of the project's CRS (e.g., "EPSG:4326") (read-only).
units(character) The map units of the project (e.g., "meters") (read-only).
Methods
Method new()
Create a new QgisProject object.
This is typically instantiated via qgis_project().
Usage
QgisProject$new(data = NULL)Method list_layers()
Lists layers available in the current QGIS project.
Method get_layer()
Reads a QGIS layer and loads it into R as a spatial object.
Arguments
x(character) The name or ID of the layer to get.
...Additional arguments passed to
sf::st_read()for vector layers.
Method insert_layer()
Inserts an R spatial object into the QGIS project as a new layer.
Arguments
layerThe spatial object to insert. Must be an
sfobject or aSpatRasterfrom theterrapackage.name(character) The desired name for the new layer in QGIS. If
NULL, a name will be generated from the object's variable name....Additional arguments passed to
sf::st_write()for vector layers.
Method get_selected_features()
Gets the selected features from the currently active vector layer in QGIS.
Method print()
Prints a summary of the QGIS project information.