1- # ' Convert a qgis_result object to an sf object
1+ # ' Convert a qgis_result object or one of its elements to an sf object
2+ # '
3+ # ' @details
4+ # ' The sf package must be loaded explicitly to use these methods.
25# '
36# ' @note Just use `st_as_sf()` in R scripts, it will use the correct
47# ' method.
1215# ' @returns An `sf` object.
1316# '
1417# ' @examplesIf has_qgis() && requireNamespace("sf", quietly = TRUE)
18+ # ' \donttest{
19+ # ' # not running below examples in R CMD check to save time
1520# ' result <- qgis_run_algorithm(
1621# ' "native:buffer",
1722# ' INPUT = system.file("longlake/longlake_depth.gpkg", package = "qgisprocess"),
2530# ' # if you need more control, extract the needed output element first:
2631# ' output_vector <- qgis_extract_output(result, "OUTPUT")
2732# ' sf::st_as_sf(output_vector)
33+ # ' }
2834# '
2935# ' @name st_as_sf
3036
3137
3238# ' @rdname st_as_sf
33- # dynamically registered in zzz.R
39+ # ' @exportS3Method sf::st_as_sf
3440st_as_sf.qgis_result <- function (x , ... ) {
3541 output <- qgis_extract_output_by_class(x , c(" qgis_outputVector" , " qgis_outputLayer" ))
3642 sf :: st_as_sf(output , ... )
3743}
3844
3945
4046# ' @rdname st_as_sf
41- # dynamically registered in zzz.R
47+ # ' @exportS3Method sf::st_as_sf
4248st_as_sf.qgis_outputVector <- function (x , ... ) {
4349 if (grepl(" \\ |layer" , x )) {
4450 output_splitted <- strsplit(x , " \\ |layer.*=" )[[1 ]]
@@ -49,7 +55,7 @@ st_as_sf.qgis_outputVector <- function(x, ...) {
4955}
5056
5157# ' @rdname st_as_sf
52- # dynamically registered in zzz.R
58+ # ' @exportS3Method sf::st_as_sf
5359st_as_sf.qgis_outputLayer <- function (x , ... ) {
5460 if (grepl(" \\ |layer" , x )) {
5561 output_splitted <- strsplit(x , " \\ |layer.*=" )[[1 ]]
0 commit comments