st_as_sf: Convert a qgis_result object or one of its elements to an sf...

st_as_sfR Documentation

Convert a qgis_result object or one of its elements to an sf object

Description

Convert a qgis_result object or one of its elements to an sf object

Usage

## S3 method for class 'qgis_result'
st_as_sf(x, ...)

## S3 method for class 'qgis_outputVector'
st_as_sf(x, ...)

## S3 method for class 'qgis_outputLayer'
st_as_sf(x, ...)

Arguments

x

A qgis_result object from qgis_run_algorithm() or a ⁠qgis_output*⁠ object from one of the qgis_extract_output() functions.

...

Arguments passed to sf::read_sf().

Details

The sf package must be loaded explicitly to use these methods.

Value

An sf object.

See Also

Other topics about coercing processing output: qgis_as_raster(), qgis_as_terra(), st_as_stars

Other topics about accessing or managing processing results: qgis_as_raster(), qgis_as_terra(), qgis_clean_result(), qgis_extract_output(), qgis_result_status(), st_as_stars

Examples



# not running below examples in R CMD check to save time
result <- qgis_run_algorithm(
  "native:buffer",
  INPUT = system.file("longlake/longlake_depth.gpkg", package = "qgisprocess"),
  DISTANCE = 10
)

# most direct approach, autoselecting a `qgis_outputVector` type
# output from the `result` object and reading as sf object:
sf::st_as_sf(result)

# if you need more control, extract the needed output element first:
output_vector <- qgis_extract_output(result, "OUTPUT")
sf::st_as_sf(output_vector)



paleolimbot/qgisprocess documentation built on Feb. 27, 2024, 9:52 p.m.