R-ArcGIS / r-bridge-install

Install the R ArcGIS Tools
Apache License 2.0
188 stars 59 forks source link

How to install R-Bridge on ArcGIS for Servers 10.5? (Help Wanted) #63

Closed wondie closed 3 years ago

wondie commented 6 years ago

I wanted to use this tool because R console couldn't run when called from Python Geoprocessing tool.

dpavlushko commented 6 years ago
  1. download latest arcgsbinding package from this location https://github.com/R-ArcGIS/r-bridge/releases/latest
  2. Run RGui, click on application menu Packages->Install package(s) from local zip files... image pick arcgisbinding_1,0,0.128.zip and install the package.
  3. Open user AppData folder, usually C:\Users\<USERNAME>\AppData\Local\ESRI. Create 'RIntergation.conf' file and and add one line: R_HOME=C:\Program Files\R\R-3.3.2 (adjust path if needed) or execute this command line:
    C:\> echo R_HOME=C:\Program Files\R\R-3.3.2 > %APPDATA%\..\Local\Esri\RIntergation.conf
wondie commented 6 years ago

Thank you very much for the help. Unfortunately, I couldn't run r scripts from my Python toolbox. I was using python subprocess.call() method to call some CMD commands calling and using r scripts. Is there a way of making this work? It works well in ArcGIS Desktop.

scw commented 6 years ago

@wondie Could you share some details on how you're trying to execute R with the package? The two main deployment stories are:

  1. Create an R script which takes inputs and outputs like any other Geoprocessing tool, and reference it within a toolbox.
  2. Create R scripts which don't use the Geoprocessing framework, but include their inputs explicitly, and write the data back via the package.

Can you use either of these above patterns? If you do need to use subprocess calls, can you provide some details about what you're trying to do? If you just need to call R from Python, you should be able to make an R script tool, then execute it from Python by importing the toolbox and calling the tool as you would with any Python tool or ModelBuilder model. If you have other reasons to need subprocess calls, share a little more about what you're doing and we can take a look.

wondie commented 6 years ago

@scw what I am using is similar to the first option. I am happy to change subprocess.call() if there is a working alternative. This is how it is used in the toolbox.


 r_cmd = '"' + r_exe_path + '" --vanilla --slave --file="' + ras_temp_path + 'out_script.r"'  # r command

        arcpy.AddMessage("Running similarity analysis \n")
        # TODO Apply this change on desktop version
        CREATE_NO_WINDOW = 0x08000000
        # Open shell and run R command
        subprocess.call(shlex.split(r_cmd), shell=False, creationflags=CREATE_NO_WINDOW)

The out_script.r contains the following command.

source("D:/mytool/R_Scripts/similarity_analysis.r"); 
similarityAnalysis(1,"D:/mytool/R_Scripts/readAscii.r","D:/mytool/R_Scripts/writeAscii.r","C:/Users/User/Documents/ArcGIS/scratch/Temp/") 

The use of the R scripts is to create ASCII files for statistics Mahalanobis and Multivariate Environmental Similarity Surfaces (MESS).

The above approach works in Desktop but not in the server.

wondie commented 6 years ago

Is there anything wrong with my implementation?

scw commented 6 years ago

@wondie I don't see anything immediately obvious. I'll need to stand up a Server instance and install R onto it to look, once I do so I'll let you know.

wondie commented 6 years ago

@scw thank you!

wondie commented 6 years ago

Could incompatibility of Python 64 bit (For server) and 32 bit for R be the cause of the problem?

MichaelGGeoda commented 5 years ago

Can anyone please comment on ArcGIS Server unable to locate R-Brigde? I have both desktop and server on the same machine. I can run R in desktop but publishing it as a GP service always bring "R Bridge not installed" from the AGS service log. Thanks!

scdub commented 5 years ago

@MichaelGGeoda Do you run Server as a different user than your personal user account? You will need to have a Rintergation.conf file in %LOCALAPPDATA%\ESRI for the Server user as well for it to find R, with the value of R_HOME set as @dpavlushko described above.

orhuna commented 5 years ago

@MichaelGGeoda, it is also worth taking a look at the enterprise documentation for arcgisbinding

scdub commented 3 years ago

Closing this issue, the above documentation can be referenced for future folks trying to install on Server.