stevenpawley / Rsagacmd

A package for linking R with the open-source SAGA-GIS
https://stevenpawley.github.io/Rsagacmd/
GNU General Public License v3.0
31 stars 3 forks source link

Error when running a tool #9

Closed RobinKohrs closed 4 years ago

RobinKohrs commented 4 years ago

Hey Steven, sorry for asking something a little naive here. I'm still a little new to R and SAGA. The issue is, that I tried to use your great package, but I get the following error Error in saga_execute(lib, tool, senv, .intern, .all_outputs, args) : when trying to run a the gpp-tool. Do you have any idea of what this might be? I can provide more infos if that would help:) Thank a lot! Robin

stevenpawley commented 4 years ago

Sorry I only noticed this issue now. I'm not familiar with using SAGA's gravitational process path (gpp) tool. However, I don't seem to have an issue generating an output:

library(Rsagacmd)
#> Loading required package: raster
#> Loading required package: sp
saga <- saga_gis()

# generate a random dem
dem <- saga$grid_calculus$random_terrain(radius = 100, iterations = 500)

# set a single cell to 1 to represent a release area
cells <- dem
cells[] <- NA
cells[50, 50] <- 1

# run tool
result <-
  saga$sim_geomorphology$gravitational_process_path_model(dem = dem, release_areas = cells)
#> No geoprocessing output for DEPOSITION. Results may require other input parameters to be specified
#> No geoprocessing output for MAX_VELOCITY. Results may require other input parameters to be specified

Created on 2020-03-12 by the reprex package (v0.3.0)

I assume that the deposition and max_velocity outputs are not generated because those depend on other arguments?

RobinKohrs commented 4 years ago

thank you very much for your answer:)! I tried your example, but I still get Error in saga_execute(lib, tool, senv, .intern, .all_outputs, args) :. Do you think that can be some issue in my saga-insalllation? I also get

In addition: Warning message: In system(saga_cmd, intern = T) : running command ''saga_cmd' --flags=p sim_geomorphology 'Gravitational Process Path Model' -DEM:'/tmp/RtmpS4MrjN/file14c9795da681.sgrd' -RELEASE_AREAS:'/tmp/RtmpS4MrjN/file14c97974af62.tif' -PROCESS_AREA:'/tmp/RtmpS4MrjN/file14c9448b73f6.sgrd' -DEPOSITION:'/tmp/RtmpS4MrjN/file14c94a510e8d.sgrd' -MAX_VELOCITY:'/tmp/RtmpS4MrjN/file14c91c0bd9da.sgrd' -STOP_POSITIONS:'/tmp/RtmpS4MrjN/file14c91f3a7e3c.sgrd'' had status 134

gisma commented 4 years ago

Could be a Missing SAGA module? Status 134 Points often to this.

RobinKohrs commented 4 years ago

great, thank you very much!! Any hint on how to approach this error? Sorry about all the questions...

gisma commented 4 years ago

Well actually this was an educated guess. I can run it with a SAGA 7.5 under Linux Manjaro but not with SAGA 6.8. However this tool is implemented shortly. So I do not think that this is an issue rised by Rsagacmd. More probably by the SAGA installation you run. It would be helpful to have this information as well as your sessionInfo().

RobinKohrs commented 4 years ago

Thank you very much for the quick response! what I consider a little strange is that I can run the gpp-model without problems using the RSAGA-öibrary aswell as the SAGA-Gui. The output of my sessioninfo() when run the above command is:

R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=de_DE.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] Rsagacmd_0.0.2 raster_3.0-12  sp_1.4-1      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3         RSAGA_1.3.0        magrittr_1.5       units_0.6-5        lattice_0.20-38    FNN_1.1.3         
 [7] rlang_0.4.4        stringr_1.4.0      plyr_1.8.5         tools_3.6.2        xts_0.12-0         rgdal_1.4-8       
[13] grid_3.6.2         gstat_2.0-3        KernSmooth_2.23-16 e1071_1.7-3        DBI_1.1.0          shapefiles_0.7    
[19] class_7.3-15       intervals_0.15.1   sf_0.8-1           purrr_0.3.3        codetools_0.2-16   stringi_1.4.6     
[25] compiler_3.6.2     XML_3.98-1.20      classInt_0.4-2     spacetime_1.2-2    foreign_0.8-75     zoo_1.8-6  
gisma commented 4 years ago

I would think about the following possivilities:

First test if the call works on the CLI witch a "pure" system call. So just export your SAGA tool call with a right click and run it according to your OS. If it works the issue ist most probably generated by Rsagacmd and I acan image @stevenpawley that this comes from a not consistent way this relatively new tool provides the arguments wich are parsed by saga_gis().

the second less likely idea that comes to my mind is that even though RSAGA has been run, the working environment may be flawed. RSAGA sets custom values for the session. If more than one SAGA installation is available, it will always use the latest one.

RobinKohrs commented 4 years ago

Thank you very much!! I used the system call and it worked. I think there is a chance that there are two installations somewhere on my system. I used 6.3 until some weeks ago but I thought that I removed it entirely now that I'm using 7.6. Maybe something went wrong deleting it. But I don't know how to check it. Maybe I could use the link2gi-library to find all saga_cmds. But for now I think I just need to stick with the gui. Thank you very much for your help!!

stevenpawley commented 4 years ago

Thanks for this discussion. I'm going to run a through tests later today to see what is occurring with multiple installed versions which have a new tool, or a change in syntax to check that nothing is going wrong.