Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a 3rd party python geoprocessing script that requires rpy2, and thus also . What is the best way to get these working together?

Using R with ArcGIS Desktop says the most useful option for using R with ArcGIS is via the Geospatial Modelling Environment but as near as I can tell GME doesn't use rpy2. The script I'd like to use is not that large, but I didn't write it and don't want to port it to a different module. I don't understand the workings well enough to be confident I could do so without making a mistake.

share|improve this question
add comment

2 Answers 2

The script should work if you have R and rpy2 installed properly. First install R, then rpy2, and be sure that you update your PATH with the rpy2 location.

See: http://rpy.sourceforge.net/rpy2/doc-dev/html/overview.html#installation

Depending how explicit the third-party script is in importing the rpy2 module you may need to set the RHOME path thusly:

from rpy_options import set_options
set_options(RHOME='C:\\Program Files\\R\\R-2.13.1\\')
share|improve this answer
    
Could you elaborate more on how you managed to install rpy2? Getting errors during installation. –  R.K. Sep 16 '12 at 3:47
add comment

Installing rpy2 in windows can be rather complex. Here are the instructions that worked for me:

1. Install R
------------
http://cran.r-project.org/bin/windows/base/


2. Install Rtools
-----------------
http://cran.r-project.org/bin/windows/Rtools/


3. Define environmental variables
---------------------------------
Control Panel | Advanced tab | Environmental Variables

define the following: RHOME, R_HOME, R_USER

examples
~~~~~~~~ 
RHOME: C:\Program Files\R\R-2.13.1
R_HOME: C:\Program Files\R\R-2.13.1
R_USER: C:\Users\username\Documents


4. Append path to R (and Rtools) executable(s) to PATH
------------------------------------------------------
Control Panel | Advanced tab | Environmental Variables

example paths: C:\Program Files\R\R-2.13.1\bin\i386; C:\Rtools\bin


5. Build rpy2
-------------
1. Download and execute the binary executable 

or 

2. Download the source and build:

In the rpy2 folder...

python setup.py build --force -c mingw32
python setup.py install

Adapted from https://bitbucket.org/lgautier/rpy2/pull-request/3/added-some-win32-install-instructions

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.