Rsagacmd icon indicating copy to clipboard operation
Rsagacmd copied to clipboard

cannot deal with SAGA installation from OSGEO4W

Open ottadini opened this issue 3 years ago • 10 comments

On Windows, a common means to install SAGA is through the OSGEO4W package installer, which is mostly an installer for QGIS. This package runs its binaries in a special environment managed through a bunch of batch files.

When saga_cmd.exe is run outside of the environment, it fails to find the required dependencies because PATH and other environment variables have not been correctly set. Is there any chance in Lytton that this env could be set through Rsagacmd's saga_env?

The workaround is to install a separate SAGA-GIS install.

ottadini avatar Aug 18 '21 11:08 ottadini

Thanks for this suggestion - I'll add the typical OSGEO4W path to SAGA's search path

stevenpawley avatar Aug 19 '21 01:08 stevenpawley

Careful with that though, as the SAGA binary won't be able to find many of the required dlls it needs to run, unless you also somehow set the environment variables correctly. Perhaps all you need to do is set PATH="%PATH%;%OSGEO4W_ROOT%\bin" for each saga_cmd session? That's where the supporting dlls seem to be, though can't guarantee that there aren't other files elsewhere.

ottadini avatar Aug 20 '21 04:08 ottadini

I just downloaded QGIS but there was not a separate option in the installation wizard to download SAGA as an additional plugin. After installing SAGA-GIS I still don't know what code to use to get R connected to SAGA...path etc. Can someone here help? Thank you!!!!

image

davidrice3 avatar Nov 22 '22 23:11 davidrice3

There is no support for the OSGEO4W version of SAGA - if you install the standalone version from the SAGA developers (binaries available for windows from sourceforge) then the saga_gis command should fine it if you install it in one of the standard locations shown in here https://stevenpawley.github.io/Rsagacmd/reference/search_saga.html. Alternatively, add the directory containing saga_cmd.exe to PATH.

stevenpawley avatar Nov 23 '22 01:11 stevenpawley

Thank you Steven, the search_saga() does not work either. I get this result...Rsagacmd is up and running. image

davidrice3 avatar Nov 23 '22 02:11 davidrice3

Oh search_saga works....just need to leave of the ()

davidrice3 avatar Nov 23 '22 02:11 davidrice3

It still cannot find it...I'm getting this msg...is there something wrong with the path I'm using?... The problem line is below, but I just can't figure out what the actual problem is. saga = saga_gis(raster_backend = "terra", vector_backend = "sf")

image

davidrice3 avatar Nov 23 '22 12:11 davidrice3

Either add the folder that contains the saga_cmd.exe, i.e., "C:/Program Files/saga-8.4.1_x64" to your user or system environment variable 'Path' and then Rsagacmd will know where it is located. Alternatively, you can do it manually every time you initiate the bridge to SAGA by:

saga = saga_gis(
  saga_bin = "C:/Program Files/saga-8.4.1_x64/saga_cmd.exe",
  raster_backend = "terra",
  vector_backend = "sf"
)

stevenpawley avatar Nov 23 '22 22:11 stevenpawley

Still relatively new to issue reporting, so apologies in advance if this post lacks details. Installed SAGA through OSGeo4W. I am unable to connect to SAGA. When I input the command below it returns an error on unable to check SAGA's version.

saga <- saga_gis(saga_bin = 'C:/OSGeo4W/apps/saga/saga_cmd.exe', raster_backend = 'terra') Error in if (saga_vers > as.numeric_version("3.0.0")) { : argument is of length zero In addition: Warning message: In system(paste(shQuote(saga_cmd), "--version"), intern = T) : running command '"C:/OSGeo4W/apps/saga/saga_cmd.exe" --version' had status 309

Unsure if this is related to what @ottadini mentioned as there isn't an error on dependencies. I really like the concept of this package and would really like to use it for a huge data pipeline as I am mostly familiar with working in R.

Pang-SEH avatar Sep 27 '23 14:09 Pang-SEH

Hello, thanks for yes. You are right that this is still the same issue. I always installed SAGA-GIS as a standalone software, probably because for a long time, the QGIS version was many versions behind. However, perhaps more people are using SAGA via OSGEO now. I'll try to look into it - the installation of SAGA through OSGEO is different and probably needs some environment variables setting first

stevenpawley avatar Sep 27 '23 15:09 stevenpawley