r-spatial / qgisprocess

R package to use QGIS processing algorithms
https://r-spatial.github.io/qgisprocess/
GNU General Public License v3.0
198 stars 20 forks source link

sagang algorithms output files in `.sdat` file format but `qgis_run_algorithm()` returns paths to `.tif` files that do not exist #149

Closed Robinlovelace closed 1 year ago

Robinlovelace commented 1 year ago

Partial reprex:

"sagang:sagawetnessindex" returns not one but four rasters -- catchment area, catchment slope, modified catchment area, and topographic wetness index.

dem_wetness = qgis_run_algorithm("sagang:sagawetnessindex",
  DEM = dem,
  .quiet = FALSE
)

We can read a selected output by providing an output name in the qgis_as_terra() function.

dem_wetness_twi_sdat = gsub("tif", "sdat", dem_wetness$TWI)
dem_wetness_twi = qgis_as_terra(dem_wetness_twi_sdat)
# plot(dem_wetness_twi)

For full reproducible example, clone the geocompx/geocompr repo, checkout the qgis branch and open in the supplied devcontainer or on a system that has the relevant dependencies installed.

Robinlovelace commented 1 year ago

Full context and work-around provided in the commit above.

florisvdh commented 1 year ago

Hi @Robinlovelace thanks for the issue. Can you paste the output of qgis_version(debug = TRUE) and cat(qgis_result_stdout(dem_wetness))? I suspect this is an upstream issue, not R's. Maybe the sagang provider or SAGA / QGIS itself. Considering that I get no problem here to get and access the .tif files, it may be due to used versions of the software.

library(qgisprocess)
#> Attempting to load the cache ... Success!
#> QGIS version: 3.30.1-'s-Hertogenbosch
#> Having access to 1289 algorithms from 9 QGIS processing providers.
#> Run `qgis_configure(use_cached_data = TRUE)` to reload cache and get more details.
#> >>> Run `qgis_enable_plugins()` to enable 1 disabled plugin(s) and
#>     access their algorithms: cartography_tools
dem <- system.file("raster/dem.tif", package = "spDataLarge")
dem_wetness <- qgis_run_algorithm("sagang:sagawetnessindex",
                                  DEM = dem)
#> Argument `WEIGHT` is unspecified (using QGIS default value).
#> Using `AREA = qgis_tmp_raster()`
#> Using `SLOPE = qgis_tmp_raster()`
#> Using `AREA_MOD = qgis_tmp_raster()`
#> Using `TWI = qgis_tmp_raster()`
#> Argument `SUCTION` is unspecified (using QGIS default value).
#> Using `AREA_TYPE = "[0] total catchment area"`
#> Using `SLOPE_TYPE = "[0] local slope"`
#> Argument `SLOPE_MIN` is unspecified (using QGIS default value).
#> Argument `SLOPE_OFF` is unspecified (using QGIS default value).
#> Argument `SLOPE_WEIGHT` is unspecified (using QGIS default value).
dem_wetness_twi <- 
  qgis_extract_output(dem_wetness, "TWI") |> 
  qgis_as_terra()

dem_wetness_twi
#> class       : SpatRaster 
#> dimensions  : 117, 117, 1  (nrow, ncol, nlyr)
#> resolution  : 30.85, 30.85  (x, y)
#> extent      : 794599.1, 798208.6, 8931775, 8935384  (xmin, xmax, ymin, ymax)
#> coord. ref. : WGS 84 / UTM zone 17S (EPSG:32717) 
#> source      : filed01c5b288977.tif 
#> name        : filed01c5b288977 
#> min value   :         7.214644 
#> max value   :        18.347366

Created on 2023-04-26 with reprex v2.0.2

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.3.0 (2023-04-21) #> os Linux Mint 21.1 #> system x86_64, linux-gnu #> ui X11 #> language nl_BE:nl #> collate nl_BE.UTF-8 #> ctype nl_BE.UTF-8 #> tz Europe/Brussels #> date 2023-04-26 #> pandoc 2.19.2 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> assertthat 0.2.1 2019-03-21 [3] CRAN (R 4.0.1) #> cli 3.6.1 2023-03-23 [3] RSPM (R 4.2.0) #> codetools 0.2-19 2023-02-01 [3] RSPM (R 4.2.0) #> digest 0.6.31 2022-12-11 [3] RSPM (R 4.2.0) #> evaluate 0.20 2023-01-17 [3] RSPM (R 4.2.0) #> fansi 1.0.4 2023-01-22 [3] RSPM (R 4.2.0) #> fastmap 1.1.1 2023-02-24 [3] RSPM (R 4.2.0) #> fs 1.6.1 2023-02-06 [3] RSPM (R 4.2.0) #> glue 1.6.2 2022-02-24 [3] RSPM (R 4.2.0) #> htmltools 0.5.5 2023-03-23 [3] RSPM (R 4.2.0) #> jsonlite 1.8.4 2022-12-06 [3] RSPM (R 4.2.0) #> knitr 1.42 2023-01-25 [3] RSPM (R 4.2.0) #> lifecycle 1.0.3 2022-10-07 [3] RSPM (R 4.2.0) #> magrittr 2.0.3 2022-03-30 [3] RSPM (R 4.2.0) #> pillar 1.9.0 2023-03-22 [3] RSPM (R 4.2.0) #> pkgconfig 2.0.3 2019-09-22 [3] CRAN (R 4.0.1) #> processx 3.8.1 2023-04-18 [3] RSPM (R 4.2.0) #> ps 1.7.5 2023-04-18 [3] RSPM (R 4.2.0) #> purrr 1.0.1 2023-01-10 [3] RSPM (R 4.2.0) #> qgisprocess * 0.0.0.9000 2023-04-26 [1] local #> R.cache 0.16.0 2022-07-21 [3] RSPM (R 4.2.0) #> R.methodsS3 1.8.2 2022-06-13 [3] RSPM (R 4.2.0) #> R.oo 1.25.0 2022-06-12 [3] RSPM (R 4.2.0) #> R.utils 2.12.2 2022-11-11 [3] RSPM (R 4.2.0) #> R6 2.5.1 2021-08-19 [3] RSPM (R 4.2.0) #> rappdirs 0.3.3 2021-01-31 [3] RSPM (R 4.2.0) #> Rcpp 1.0.10 2023-01-22 [3] RSPM (R 4.2.0) #> reprex 2.0.2 2022-08-17 [3] RSPM (R 4.2.0) #> rlang 1.1.0 2023-03-14 [3] RSPM (R 4.2.0) #> rmarkdown 2.21 2023-03-26 [3] RSPM (R 4.2.0) #> rstudioapi 0.14 2022-08-22 [3] RSPM (R 4.2.0) #> sessioninfo 1.2.2 2021-12-06 [3] RSPM (R 4.2.0) #> stringi 1.7.12 2023-01-11 [3] RSPM (R 4.2.0) #> stringr 1.5.0 2022-12-02 [3] RSPM (R 4.2.0) #> styler 1.9.1 2023-03-04 [3] RSPM (R 4.2.0) #> terra 1.7-29 2023-04-22 [1] CRAN (R 4.2.3) #> tibble 3.2.1 2023-03-20 [3] RSPM (R 4.2.0) #> utf8 1.2.3 2023-01-31 [3] RSPM (R 4.2.0) #> vctrs 0.6.2 2023-04-19 [3] RSPM (R 4.2.0) #> withr 2.5.0 2022-03-03 [3] RSPM (R 4.2.0) #> xfun 0.39 2023-04-20 [3] RSPM (R 4.2.0) #> yaml 2.3.7 2023-01-23 [3] RSPM (R 4.2.0) #> #> [1] /home/floris/lib/R/library #> [2] /usr/local/lib/R/site-library #> [3] /usr/lib/R/site-library #> [4] /usr/lib/R/library #> #> ────────────────────────────────────────────────────────────────────────────── ```

This is using the qgis_extract_output() function from the single_output_fvdh branch.

Some debug info ```r > qgis_version(debug = TRUE) [1] "3.30.1-'s-Hertogenbosch" Versions reported by 'qgis_process': ------------------------------------ QGIS 3.30.1-'s-Hertogenbosch ''s-Hertogenbosch' (447e8d717a) QGIS code revision 447e8d717a Qt version 5.15.3 Python version 3.10.6 GDAL/OGR version 3.6.2 PROJ version 9.1.1 EPSG Registry database version v10.076 (2022-08-31) GEOS version 3.11.1-CAPI-1.17.1 SQLite version 3.37.2 OS Linux Mint 21.1 > cat(qgis_result_stdout(dem_wetness)) { "algorithm_details": { "can_cancel": true, "deprecated": false, "group": "Terrain Analysis - Hydrology", "has_known_issues": false, "help_url": null, "id": "sagang:sagawetnessindex", "name": "Saga wetness index", "requires_matching_crs": false, "short_description": null, "tags": [] }, "gdal_version": "3.6.2", "geos_version": "3.11.1-CAPI-1.17.1", "inputs": { "AREA": "/tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e95227335a.tif", "AREA_MOD": "/tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e92fc94392.tif", "AREA_TYPE": 0, "DEM": "/home/floris/lib/R/library/spDataLarge/raster/dem.tif", "SLOPE": "/tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e978e636d4.tif", "SLOPE_TYPE": 0, "TWI": "/tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e93cdde3c8.tif" }, "log": { "info": [ "io_gdal 0 -TRANSFORM 1 -RESAMPLING 3 -GRIDS \"/tmp/processing_ZGJDUq/9022dc7da7ca406c89927b794cf9dc65/dem.sgrd\" -FILES \"/home/floris/lib/R/library/spDataLarge/raster/dem.tif\"", "ta_hydrology \"SAGA Wetness Index\" -DEM \"/tmp/processing_ZGJDUq/9022dc7da7ca406c89927b794cf9dc65/dem.sgrd\" -AREA_TYPE 0 -SLOPE_TYPE 0 -AREA \"/tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e95227335a.tif\" -SLOPE \"/tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e978e636d4.tif\" -AREA_MOD \"/tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e92fc94392.tif\" -TWI \"/tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e93cdde3c8.tif\"", "____________________________", "", "##### ## ##### ##", "### ### ## ###", "### # ## ## #### # ##", "### ##### ## # #####", "##### # ## ##### # ##", "____________________________", "", "SAGA Version: 8.2.2", "", "____________________________", "library path: /usr/lib/x86_64-linux-gnu/saga/", "library name: libio_gdal", "library : io_gdal", "tool : Import Raster", "identifier : 0", "author : O.Conrad (c) 2007 (A.Ringeler)", "processors : 8 [8]", "____________________________", "", "[Import Raster] Execution started...", "", "__________", "[Import Raster] Parameters:", "", "Grids: No objects", "Files: \"/home/floris/lib/R/library/spDataLarge/raster/dem.tif\"", "Multiple Bands Output: automatic", "Select from Multiple Bands:", "Transformation: true", "Resampling: B-Spline Interpolation", "Extent: original", "", "", "loading: /home/floris/lib/R/library/spDataLarge/raster/dem.tif", "", "", "", "Driver: GTiff", "", "Bands: 1", "", "Rows: 117", "", "Columns: 117", "", "", "", "Transformation:", "", "x' = 794599.107615 + x * 30.850000 + y * 0.000000", "", "y' = 8935384.324603 + x * 0.000000 + y * -30.850000", "", "", "loading: dem", "", "", "", "warning: top-to-bottom and left-to-right cell sizes differ.", "Difference: 0.000000", "", "using cellsize: 30.850000", "", "", "", "__________", "total execution time: 0 milliseconds (less than 1 millisecond)", "", "[Import Raster] Execution succeeded (less than 1 millisecond)", "", "Saving grid: /tmp/processing_ZGJDUq/9022dc7da7ca406c89927b794cf9dc65/dem.sgrd...", "", "", "okay", "corrupted size vs. prev_size", "Aborted (core dumped)", "____________________________", "", "##### ## ##### ##", "### ### ## ###", "### # ## ## #### # ##", "### ##### ## # #####", "##### # ## ##### # ##", "____________________________", "", "SAGA Version: 8.2.2", "", "____________________________", "library path: /usr/lib/x86_64-linux-gnu/saga/", "library name: libta_hydrology", "library : ta_hydrology", "tool : SAGA Wetness Index", "identifier : 15", "author : J.Boehner, O.Conrad (c) 2001", "processors : 8 [8]", "____________________________", "", "Loading grid: /tmp/processing_ZGJDUq/9022dc7da7ca406c89927b794cf9dc65/dem.sgrd...", "", "", "", "okay", "[SAGA Wetness Index] Execution started...", "", "__________", "[SAGA Wetness Index] Parameters:", "", "Grid System: 30.850000; 117x 117y; 794614.532615x 8931790.299603y", "Elevation: dem", "Weights: ", "Catchment Area: Catchment Area", "Catchment Slope: Catchment Slope", "Modified Catchment Area: Modified Catchment Area", "Topographic Wetness Index: Topographic Wetness Index", "Suction: 10", "Type of Area: total catchment area", "Type of Slope: local slope", "Minimum Slope: 0", "Offset Slope: 0.1", "Slope Weighting: 1", "", "", "", "Create index: dem", "", "", "catchment area and slope...", "", "", "", "pass 1 (1362 > 0)", "pass 2 (621 > 0)", "pass 3 (394 > 0)", "pass 4 (246 > 0)", "pass 5 (144 > 0)", "pass 6 (62 > 0)", "pass 7 (27 > 0)", "pass 8 (13 > 0)", "pass 9 (1 > 0)", "pass 10 (0 > 0)", "post-processing...", "topographic wetness index...", "", "__________", "total execution time: 1000 milliseconds (01s)", "", "[SAGA Wetness Index] Execution succeeded (01s)", "Saving grid: /tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e95227335a.tif...", "Export GeoTIFF", "", "__________", "[Export GeoTIFF] Parameters:", "", "Grid System: 30.850000; 117x 117y; 794614.532615x 8931790.299603y", "Grid(s): 1 object (fileb8e95227335a)", "File: /tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e95227335a.tif", "Creation Options:", "", "Band 1", "", "", "", "", "[Export GeoTIFF] execution time: less than 1 millisecond", "okay", "Saving grid: /tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e978e636d4.tif...", "Export GeoTIFF", "", "__________", "[Export GeoTIFF] Parameters:", "", "Grid System: 30.850000; 117x 117y; 794614.532615x 8931790.299603y", "Grid(s): 1 object (fileb8e978e636d4)", "File: /tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e978e636d4.tif", "Creation Options:", "", "Band 1", "", "", "", "", "[Export GeoTIFF] execution time: less than 1 millisecond", "okay", "Saving grid: /tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e92fc94392.tif...", "Export GeoTIFF", "", "__________", "[Export GeoTIFF] Parameters:", "", "Grid System: 30.850000; 117x 117y; 794614.532615x 8931790.299603y", "Grid(s): 1 object (fileb8e92fc94392)", "File: /tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e92fc94392.tif", "Creation Options:", "", "Band 1", "", "", "", "", "[Export GeoTIFF] execution time: less than 1 millisecond", "okay", "Saving grid: /tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e93cdde3c8.tif...", "Export GeoTIFF", "", "__________", "[Export GeoTIFF] Parameters:", "", "Grid System: 30.850000; 117x 117y; 794614.532615x 8931790.299603y", "Grid(s): 1 object (fileb8e93cdde3c8)", "File: /tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e93cdde3c8.tif", "Creation Options:", "", "Band 1", "", "", "", "", "[Export GeoTIFF] execution time: less than 1 millisecond", "okay" ] }, "proj_version": "Rel. 9.1.1, December 1st, 2022", "provider_details": { "can_be_activated": true, "default_raster_file_extension": "sdat", "default_vector_file_extension": "shp", "is_active": true, "long_name": "SAGA Next Gen (8.2.2)", "name": "SAGA Next Gen", "supported_output_raster_extensions": [ "sdat" ], "supported_output_table_extensions": [ "dbf" ], "supported_output_vector_extensions": [ "shp", "dbf" ], "supports_non_file_based_output": false, "version": "0.0.7" }, "python_version": "3.10.6", "qgis_code_revision": "447e8d717a", "qgis_version": "3.30.1-'s-Hertogenbosch", "qt_version": "5.15.3", "results": { "AREA": "/tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e95227335a.tif", "AREA_MOD": "/tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e92fc94392.tif", "SLOPE": "/tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e978e636d4.tif", "TWI": "/tmp/RtmpC0pYRs/fileb8e93643ba83/fileb8e93cdde3c8.tif" } } ```
Robinlovelace commented 1 year ago

You should be able to reproduce the issue with...

docker run -it geocompr/geocompr:qgis /bin/bash

Or similar. Will check now...

Robinlovelace commented 1 year ago

I get:

qgis_version(debug = TRUE) 
[1] "3.30.1-'s-Hertogenbosch"

Versions reported by 'qgis_process':
------------------------------------
QGIS 3.30.1-'s-Hertogenbosch ''s-Hertogenbosch' (447e8d717a)
QGIS code revision 447e8d717a
Qt version 5.15.3
Python version 3.10.6
GDAL/OGR version 3.4.1
PROJ version 8.2.1
EPSG Registry database version v10.041 (2021-12-03)
GEOS version 3.10.2-CAPI-1.16.0
SQLite version 3.37.2
OS Ubuntu 22.04.2 LTS
Robinlovelace commented 1 year ago

I can still reproduce the issue. Agree, it may be due to upstream changes associated with that particular version of QGIS. Do we need a more recent version? @jannes-m was advocating for that but I switched to the default versions of stuff due to an issue (which is fixable) in rocker images.

``` docker run -it ghcr.io/geocompx/docker:qgis /bin/bash root@804ac03d564d:/# R R version 4.2.3 (2023-03-15) -- "Shortstop Beagle" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(qgisprocess) Attempting to load the cache ... Success! QGIS version: 3.30.1-'s-Hertogenbosch Having access to 349 algorithms from 4 QGIS processing providers. Run `qgis_configure(use_cached_data = TRUE)` to reload cache and get more details. >>> Run `qgis_enable_plugins()` to enable 3 disabled plugin(s) and access their algorithms: grassprovider, otbprovider, processing_saga_nextgen > qgis_enable_plugins() Trying to enable following plugin(s): grassprovider, otbprovider, processing_saga_nextgen grassprovider successfully enabled! otbprovider successfully enabled! processing_saga_nextgen successfully enabled! Rebuilding cache to reflect these changes ... getOption('qgisprocess.path') was not found. Sys.getenv('R_QGISPROCESS_PATH') was not found. Trying 'qgis_process' on PATH... Success! Now using 'qgis_process' in the system PATH. >>> If you need another installed QGIS instance, run `qgis_configure()`; see `?qgis_configure` if you need to preset the path of 'qgis_process'. QGIS version is now set to: 3.30.1-'s-Hertogenbosch Using JSON for output serialization. Using JSON for input serialization. 4 out of 4 available processing provider plugins are enabled. You now have access to 1162 algorithms from 6 QGIS processing providers. Saving configuration to '~/.cache/R-qgisprocess/cache-0.0.0.9000.rds' Use qgis_algorithms(), qgis_providers(), qgis_plugins(), qgis_use_json_output(), qgis_path() and qgis_version() to inspect the cache environment. > dem = rast(system.file("raster/dem.tif", package = "spDataLarge")) Error in rast(system.file("raster/dem.tif", package = "spDataLarge")) : could not find function "rast" > library(terra) terra 1.7.18 > dem = rast(system.file("raster/dem.tif", package = "spDataLarge")) > qgis_version(debug = TRUE) [1] "3.30.1-'s-Hertogenbosch" Versions reported by 'qgis_process': ------------------------------------ QGIS 3.30.1-'s-Hertogenbosch ''s-Hertogenbosch' (447e8d717a) QGIS code revision 447e8d717a Qt version 5.15.3 Python version 3.10.6 GDAL/OGR version 3.4.1 PROJ version 8.2.1 EPSG Registry database version v10.041 (2021-12-03) GEOS version 3.10.2-CAPI-1.16.0 SQLite version 3.37.2 OS Ubuntu 22.04.2 LTS > dem_wetness <- qgis_run_algorithm("sagang:sagawetnessindex", DEM = dem) Argument `WEIGHT` is unspecified (using QGIS default value). Using `AREA = qgis_tmp_raster()` Using `SLOPE = qgis_tmp_raster()` Using `AREA_MOD = qgis_tmp_raster()` Using `TWI = qgis_tmp_raster()` Argument `SUCTION` is unspecified (using QGIS default value). Using `AREA_TYPE = "[0] total catchment area"` Using `SLOPE_TYPE = "[0] local slope"` Argument `SLOPE_MIN` is unspecified (using QGIS default value). Argument `SLOPE_OFF` is unspecified (using QGIS default value). Argument `SLOPE_WEIGHT` is unspecified (using QGIS default value). QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' Problem with OTB installation: OTB folder is not set. > dem_wetness <- qgis_run_algorithm("sagang:sagawetnessindex", DEM = dem) Argument `WEIGHT` is unspecified (using QGIS default value). Using `AREA = qgis_tmp_raster()` Using `SLOPE = qgis_tmp_raster()` Using `AREA_MOD = qgis_tmp_raster()` Using `TWI = qgis_tmp_raster()` Argument `SUCTION` is unspecified (using QGIS default value). Using `AREA_TYPE = "[0] total catchment area"` Using `SLOPE_TYPE = "[0] local slope"` Argument `SLOPE_MIN` is unspecified (using QGIS default value). Argument `SLOPE_OFF` is unspecified (using QGIS default value). Argument `SLOPE_WEIGHT` is unspecified (using QGIS default value). QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' Problem with OTB installation: OTB folder is not set. > dem_wetness_twi = qgis_as_terra(dem_wetness$TWI) Error: [rast] file does not exist: /tmp/Rtmp0E8stc/filed7e75bb17/filed349c119b.tif In addition: Warning message: /tmp/Rtmp0E8stc/filed7e75bb17/filed349c119b.tif: No such file or directory (GDAL error 4) > dem_wetness_twi = qgis_as_terra(dem_wetness$TWI) Error: [rast] file does not exist: /tmp/Rtmp0E8stc/filed7e75bb17/filed349c119b.tif In addition: Warning message: /tmp/Rtmp0E8stc/filed7e75bb17/filed349c119b.tif: No such file or directory (GDAL error 4) > dem_wetness_twi_sdat = gsub("tif", "sdat", dem_wetness$TWI) > dem_wetness_twi = qgis_as_terra(dem_wetness_twi_sdat) ```
jannes-m commented 1 year ago

I think this problem disappeared when using the ubuntugis unstable installation (with Ubuntu 22.04) though the qgis version was the same. In any case I wouldn't bet that it stays this way or is this way on every other platform. This problem already exists for too long...

Robinlovelace commented 1 year ago

Good point Jannes. If it can be a self-fixing issue I'm happy : )

Worth fixing upstream? I've created this placeholder, v. happy if you or anyone can have a bash: https://github.com/geocompx/docker/issues/37 and that may fix it :crossed_fingers:

florisvdh commented 1 year ago

I think this problem disappeared when using the ubuntugis unstable installation

Yes that may be it. The Ubuntu repo has SAGA 7.3, the ubuntugis-unstable PPA has 8.2.2.

$ apt policy saga
saga:
  Installed: 8.2.2+dfsg-1~jammy0
  Candidate: 8.2.2+dfsg-1~jammy0
  Version table:
 *** 8.2.2+dfsg-1~jammy0 500
        500 http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu jammy/main amd64 Packages
        100 /var/lib/dpkg/status
     7.3.0+dfsg-7 500
        500 http://ftp.belnet.be/ubuntu jammy/universe amd64 Packages

The output of cat(qgis_result_stdout(dem_wetness)) will show you which SAGA version was called.

Robinlovelace commented 1 year ago

That's good context, fixed in later versions of SAGA, and not worth supporting ephemeral out-of-date versions. Happy for this to be closed, think we need to the issue our side in the qgis image we're shipping.

florisvdh commented 1 year ago

Yes, better to not create workarounds in the R package to manage upstream problems, unless they are widespread or not getting solved. Better is to post the issue upstream if not already fixed.

For continuous integration purposes in combination with the ubuntugis-unstable PPA (= where the official GRASS release lives), you should probably use QGIS from its ubuntugis-nightly repo, since that repo provides instant QGIS rebuilds against the ubuntugis-unstable PPA. That means, whenever GRASS etc. is updated at the ubuntugis-unstable PPA, the regular ubuntugis QGIS build (which too is tailored for using that PPA) remains out-of-sync with the PPA (until start of next month) and may temporarily not be installable together with GRASS from the PPA (this situation occurred a month ago in this repo).

Feel free to close when you think this needs no further effort here. Discussion can continue of course.

Robinlovelace commented 1 year ago

Thanks @florisvdh agreed, this is not an issue for this codebase. Ported to https://github.com/geocompx/docker/issues/37. Good discussion and many thanks for the pointers to well supported repos.

florisvdh commented 1 year ago

Assuming that the conflict has to do with the SAGA version, and that older SAGA versions only supported its native .sdat output format (by design), it means following approaches seem possible when trying to meet (older) SAGA expectations – the last one only in theory though:

xiaoxuan6722 commented 4 months ago

library(qgisprocess) Attempting to load the package cache ... Success! QGIS version: 3.36.0-Maidenhead Having access to 698 algorithms from 7 QGIS processing providers. Run qgis_configure(use_cached_data = TRUE) to reload cache and get more details.

qgis_search_algorithms("buffer")

A tibble: 11 × 5

provider provider_title group algorithm algorithm_title

1 gdal GDAL Vector geoprocessing gdal:buffervectors Buffer vectors 2 gdal GDAL Vector geoprocessing gdal:onesidebuffer One side buffer 3 grass GRASS Raster (r.*) grass:r.buffer r.buffer 4 grass GRASS Raster (r.*) grass:r.buffer.lowmem r.buffer.lowmem 5 grass GRASS Vector (v.*) grass:v.buffer v.buffer 6 native QGIS (native c++) Vector geometry native:buffer Buffer 7 native QGIS (native c++) Vector geometry native:bufferbym Variable width b… 8 native QGIS (native c++) Vector geometry native:multiringconstantbuffer Multi-ring buffe… 9 native QGIS (native c++) Vector geometry native:singlesidedbuffer Single sided buf… 10 native QGIS (native c++) Vector geometry native:taperedbuffer Tapered buffers 11 native QGIS (native c++) Vector geometry native:wedgebuffers Create wedge buf… qgis_search_algorithms("wetness") # A tibble: 0 × 5 # ℹ 5 variables: provider , provider_title , group , algorithm , # algorithm_title topo_total=qgisprocess::qgis_run_algorithm( + alg="sagang:sagawetnessindex", + DEM=doubs_dem_utm_masked, + SLOPE_TYPE=1, + SLOPE= tempfile(fileext = ".sdat"), + AREA= tempfile(fileext = ".sdat"), + .quiet=TRUE + ) Error in `assert_qgis_algorithm()`: ! Can't find QGIS algorithm 'sagang:sagawetnessindex'. Run `qgis_algorithms()` for a list of available algorithms. Run `rlang::last_trace()` to see where the error occurred.

How can I solve this problem

xiaoxuan6722 commented 4 months ago

library(qgisprocess) Attempting to load the package cache ... Success! QGIS version: 3.36.0-Maidenhead Having access to 698 algorithms from 7 QGIS processing providers. Run qgis_configure(use_cached_data = TRUE) to reload cache and get more details.

qgis_search_algorithms("buffer")

A tibble: 11 × 5

provider provider_title group algorithm algorithm_title

1 gdal GDAL Vector geoprocessing gdal:buffervectors Buffer vectors 2 gdal GDAL Vector geoprocessing gdal:onesidebuffer One side buffer 3 grass GRASS Raster (r.*) grass:r.buffer r.buffer 4 grass GRASS Raster (r.*) grass:r.buffer.lowmem r.buffer.lowmem 5 grass GRASS Vector (v.*) grass:v.buffer v.buffer 6 native QGIS (native c++) Vector geometry native:buffer Buffer 7 native QGIS (native c++) Vector geometry native:bufferbym Variable width b… 8 native QGIS (native c++) Vector geometry native:multiringconstantbuffer Multi-ring buffe… 9 native QGIS (native c++) Vector geometry native:singlesidedbuffer Single sided buf… 10 native QGIS (native c++) Vector geometry native:taperedbuffer Tapered buffers 11 native QGIS (native c++) Vector geometry native:wedgebuffers Create wedge buf… qgis_search_algorithms("wetness") # A tibble: 0 × 5 # ℹ 5 variables: provider , provider_title , group , algorithm , # algorithm_title topo_total=qgisprocess::qgis_run_algorithm( + alg="sagang:sagawetnessindex", + DEM=doubs_dem_utm_masked, + SLOPE_TYPE=1, + SLOPE= tempfile(fileext = ".sdat"), + AREA= tempfile(fileext = ".sdat"), + .quiet=TRUE + ) Error in `assert_qgis_algorithm()`: ! Can't find QGIS algorithm 'sagang:sagawetnessindex'. Run `qgis_algorithms()` for a list of available algorithms. Run `rlang::last_trace()` to see where the error occurred.

How can I solve this problem