st_as_stars: Convert a qgis_result object or one of its elements to a...

st_as_starsR Documentation

Convert a qgis_result object or one of its elements to a stars object

Description

Convert a qgis_result object or one of its elements to a stars object

Usage

st_as_stars.qgis_outputRaster(x, ...)

st_as_stars.qgis_outputLayer(x, ...)

st_as_stars.qgis_result(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 stars::read_stars().

Details

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

Value

A stars or a stars_proxy object.

Note

Just use st_as_stars() in R scripts, it will use the correct method.

See Also

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

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_sf

Examples



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

# most direct approach, autoselecting a `qgis_outputRaster` type
# output from the `result` object and reading as stars or stars_proxy:
stars::st_as_stars(result)
stars::st_as_stars(result, proxy = TRUE)

# if you need more control, extract the needed output element first:
output_raster <- qgis_extract_output(result, "OUTPUT")
stars::st_as_stars(output_raster)



qgisprocess documentation built on Aug. 17, 2023, 5:14 p.m.