Convert a qgis_result object or one of its elements to a stars object
Source:R/compat-stars.R
st_as_stars.Rd
Convert a qgis_result object or one of its elements to a stars object
Usage
# S3 method for class 'qgis_outputRaster'
st_as_stars(x, ...)
# S3 method for class 'qgis_outputLayer'
st_as_stars(x, ...)
# S3 method for class 'qgis_result'
st_as_stars(x, ...)
Arguments
- x
A
qgis_result
object fromqgis_run_algorithm()
or aqgis_output*
object from one of theqgis_extract_output()
functions.- ...
Arguments passed to
stars::read_stars()
.
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
# \donttest{
# 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")
)
#> Argument `Z_FACTOR` is unspecified (using QGIS default value).
#> Using `OUTPUT = qgis_tmp_raster()`
# 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 object with 2 dimensions and 1 attribute
#> attribute(s):
#> Min. 1st Qu. Median Mean 3rd Qu.
#> file2b045445b2e4.tif 0.008276554 0.2864364 0.4271587 0.4269891 0.5803983
#> Max. NA's
#> file2b045445b2e4.tif 0.8075118 6475
#> dimension(s):
#> from to offset delta refsys point x/y
#> x 1 100 409940 18.27 NAD83 / UTM zone 20N FALSE [x]
#> y 1 100 5084861 -15.54 NAD83 / UTM zone 20N FALSE [y]
stars::st_as_stars(result, proxy = TRUE)
#> stars_proxy object with 1 attribute in 1 file(s):
#> $file2b045445b2e4.tif
#> [1] "[...]/file2b045445b2e4.tif"
#>
#> dimension(s):
#> from to offset delta refsys point x/y
#> x 1 100 409940 18.27 NAD83 / UTM zone 20N FALSE [x]
#> y 1 100 5084861 -15.54 NAD83 / UTM zone 20N FALSE [y]
# if you need more control, extract the needed output element first:
output_raster <- qgis_extract_output(result, "OUTPUT")
stars::st_as_stars(output_raster)
#> stars object with 2 dimensions and 1 attribute
#> attribute(s):
#> Min. 1st Qu. Median Mean 3rd Qu.
#> file2b045445b2e4.tif 0.008276554 0.2864364 0.4271587 0.4269891 0.5803983
#> Max. NA's
#> file2b045445b2e4.tif 0.8075118 6475
#> dimension(s):
#> from to offset delta refsys point x/y
#> x 1 100 409940 18.27 NAD83 / UTM zone 20N FALSE [x]
#> y 1 100 5084861 -15.54 NAD83 / UTM zone 20N FALSE [y]
# }