Skip to content

Commit 9da1e62

Browse files
committed
Merge branch 'main' into cran_submission_0.1.0
2 parents 44a2855 + cf95154 commit 9da1e62

20 files changed

+99
-44
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ License: GPL (>= 3)
3030
URL: https://r-spatial.github.io/qgisprocess/,
3131
https://github.com/r-spatial/qgisprocess
3232
BugReports: https://github.com/r-spatial/qgisprocess/issues
33+
Depends: R (>= 3.6.0)
3334
Imports:
3435
assertthat,
3536
glue,

NAMESPACE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ S3method(qgis_clean_argument,qgis_list_input)
4848
S3method(qgis_clean_argument,qgis_tempfile_arg)
4949
S3method(qgis_run_algorithm_p,default)
5050
S3method(qgis_run_algorithm_p,qgis_result)
51+
S3method(sf::st_as_sf,qgis_outputLayer)
52+
S3method(sf::st_as_sf,qgis_outputVector)
53+
S3method(sf::st_as_sf,qgis_result)
54+
S3method(stars::st_as_stars,qgis_outputLayer)
55+
S3method(stars::st_as_stars,qgis_outputRaster)
56+
S3method(stars::st_as_stars,qgis_result)
5157
export(as_qgis_argument)
5258
export(has_qgis)
5359
export(qgis_algorithms)

R/compat-raster.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#' Convert a qgis_result object or one of its elements to a raster object
22
#'
3-
#' @note Just use `qgis_as_raster()` and `qgis_as_brick()` in R scripts;
4-
#' it will use the correct method.
5-
#'
63
#' @family topics about coercing processing output
74
#' @family topics about accessing or managing processing results
85
#'
@@ -13,6 +10,8 @@
1310
#' @returns A `RasterLayer` or a `RasterBrick` object.
1411
#'
1512
#' @examplesIf has_qgis() && requireNamespace("raster", quietly = TRUE)
13+
#' \donttest{
14+
#' # not running below examples in R CMD check to save time
1615
#' result <- qgis_run_algorithm(
1716
#' "native:slope",
1817
#' INPUT = system.file("longlake/longlake_depth.tif", package = "qgisprocess")
@@ -25,6 +24,7 @@
2524
#' # if you need more control, extract the needed output element first:
2625
#' output_raster <- qgis_extract_output(result, "OUTPUT")
2726
#' qgis_as_raster(output_raster)
27+
#' }
2828
#'
2929
#' @name qgis_as_raster
3030

R/compat-sf.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
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.
@@ -12,6 +15,8 @@
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"),
@@ -25,20 +30,21 @@
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
3440
st_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
4248
st_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
5359
st_as_sf.qgis_outputLayer <- function(x, ...) {
5460
if (grepl("\\|layer", x)) {
5561
output_splitted <- strsplit(x, "\\|layer.*=")[[1]]

R/compat-stars.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#' Convert a qgis_result object or one of its elements to a stars object
22
#'
3+
#' @details
4+
#' The stars package must be loaded explicitly to use these methods.
5+
#'
36
#' @note Just use `st_as_stars()` in R scripts, it will use the correct
47
#' method.
58
#'
@@ -12,6 +15,8 @@
1215
#' @returns A `stars` or a `stars_proxy` object.
1316
#'
1417
#' @examplesIf has_qgis() && requireNamespace("stars", quietly = TRUE)
18+
#' \donttest{
19+
#' # not running below examples in R CMD check to save time
1520
#' result <- qgis_run_algorithm(
1621
#' "native:slope",
1722
#' INPUT = system.file("longlake/longlake_depth.tif", package = "qgisprocess")
@@ -25,23 +30,24 @@
2530
#' # if you need more control, extract the needed output element first:
2631
#' output_raster <- qgis_extract_output(result, "OUTPUT")
2732
#' stars::st_as_stars(output_raster)
33+
#' }
2834
#'
2935
#' @name st_as_stars
3036

3137
#' @rdname st_as_stars
32-
# dynamically registered in zzz.R
38+
#' @exportS3Method stars::st_as_stars
3339
st_as_stars.qgis_outputRaster <- function(x, ...) {
3440
stars::read_stars(unclass(x), ...)
3541
}
3642

3743
#' @rdname st_as_stars
38-
# dynamically registered in zzz.R
44+
#' @exportS3Method stars::st_as_stars
3945
st_as_stars.qgis_outputLayer <- function(x, ...) {
4046
stars::read_stars(unclass(x), ...)
4147
}
4248

4349
#' @rdname st_as_stars
44-
# dynamically registered in zzz.R
50+
#' @exportS3Method stars::st_as_stars
4551
st_as_stars.qgis_result <- function(x, ...) {
4652
result <- qgis_extract_output_by_class(x, c("qgis_outputRaster", "qgis_outputLayer"))
4753
stars::read_stars(unclass(result), ...)

R/compat-terra.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#' Convert a qgis_result object or one of its elements to a terra object
22
#'
3-
#' @note Just use `qgis_as_terra()` in R scripts, it will use the correct
4-
#' method.
5-
#'
63
#' @family topics about coercing processing output
74
#' @family topics about accessing or managing processing results
85
#'
@@ -12,6 +9,8 @@
129
#' @returns A `SpatRaster` or a `SpatVector` object.
1310
#'
1411
#' @examplesIf has_qgis() && requireNamespace("terra", quietly = TRUE)
12+
#' \donttest{
13+
#' # not running below examples in R CMD check to save time
1514
#' result <- qgis_run_algorithm(
1615
#' "native:slope",
1716
#' INPUT = system.file("longlake/longlake_depth.tif", package = "qgisprocess")
@@ -24,6 +23,7 @@
2423
#' # if you need more control, extract the needed output element first:
2524
#' output_raster <- qgis_extract_output(result, "OUTPUT")
2625
#' qgis_as_terra(output_raster)
26+
#' }
2727
#'
2828
#' @name qgis_as_terra
2929

R/qgis-configure.R

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,16 @@
4242
#' @returns The result of [processx::run()].
4343
#'
4444
#' @examples
45+
#' \donttest{
46+
#' # not running in R CMD check to save time
4547
#' qgis_configure(use_cached_data = TRUE)
48+
#' }
4649
#'
47-
#' # Not run in the examples:
48-
#' if (FALSE) qgis_configure()
50+
#' \dontrun{
51+
#' # package reconfiguration
52+
#' # (not run in example() as it rewrites the package cache file)
53+
#' qgis_configure()
54+
#' }
4955
#'
5056
#' @export
5157
qgis_configure <- function(quiet = FALSE, use_cached_data = FALSE) {
@@ -358,8 +364,15 @@ qgis_env <- function() {
358364
#' @returns `NULL`, invisibly.
359365
#'
360366
#' @examples
361-
#' if (FALSE) {
362-
#' qgis_unconfigure()
367+
#' \dontrun{
368+
#' # not running this function in example() as it clears the cache environment.
369+
#' qgis_unconfigure()
370+
#' }
371+
#'
372+
#' # undoing qgis_unconfigure() by repopulating the cache environment from file:
373+
#' \donttest{
374+
#' # not running in R CMD check to save time
375+
#' qgis_configure(use_cached_data = TRUE)
363376
#' }
364377
#'
365378
#' @export

R/qgis-help.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
#'
1313
#' @examplesIf has_qgis()
1414
#' qgis_get_description("native:filedownloader")
15+
#' \donttest{
16+
#' # not running below examples in R CMD check to save time
1517
#' qgis_get_argument_specs("native:filedownloader")
1618
#' qgis_get_output_specs("native:filedownloader")
1719
#' qgis_show_help("native:filedownloader")
20+
#' }
1821
#'
1922
#' @export
2023
qgis_show_help <- function(algorithm) {

R/zzz.R

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
.onLoad <- function(...) {
44
qgis_configure(quiet = TRUE, use_cached_data = TRUE)
55

6-
vctrs::s3_register("sf::st_as_sf", "qgis_result")
7-
vctrs::s3_register("sf::st_as_sf", "qgis_outputVector")
8-
vctrs::s3_register("sf::st_as_sf", "qgis_outputLayer")
9-
vctrs::s3_register("stars::st_as_stars", "qgis_result")
10-
vctrs::s3_register("stars::st_as_stars", "qgis_outputLayer")
11-
vctrs::s3_register("stars::st_as_stars", "qgis_outputRaster")
12-
136
# create package temporary directory
147
qgisprocess_internal_obj$qgis_tmp_dir_location <- tempfile()
158
dir.create(qgisprocess_internal_obj$qgis_tmp_dir_location)

man/qgis_as_raster.Rd

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)