14

I'm finding that much of the QGIS documentation is oriented toward use of the GUI.

I want to be able to run R scripts in QGIS, but am having trouble finding a resource that will ground me in the relationship between QGIS and R data structures and how to pass structures between the two. A related question (Is it possible to create and run custom R scripts in QGIS 2.0?) directed me to this page: http://www.qgis.org/en/docs/user_manual/processing/3rdParty.html, but the I'm finding the documentation there is coming at things from more of a QGIS-expert direction than what I'm looking for.

Any suggestions?

  • Can you be more specific as of what you mean with data structures? R can read and write shapefiles (see the rgdal library) for example, and so can Qgis -- if this is what you need. – cengel Nov 6 '13 at 17:03
20

The principle is simple if you have R installed and is usable in command line.

You can create and/or execute a R Script from QGIS using Processing in QGIS version 2.0 or Sextante in version 1.8):

enter image description here

see:

  • These are helpful. I'm beginning to realize the thing that I'd really like is a REPL (Read-Eval-Print-Loop) interface where I can enter both commands from R with builtin QGIS commands, and then later combine these commands into a script. I'm hoping for this both because it's a comfortable learning environment and because I ultimately it would save me a great deal of time to be able to write scripts that combine GIS tools with R. I'm beginning to think (especially after reading your last link) that such an environment might be impossible. Do you have anything to add on this? – user1521655 Nov 7 '13 at 15:10
  • you can directly use QGIS, GRASS GIS or R from Python at the same time. You can use R in the Python console of QGIS (scienceoss.com/rpy-statistics-in-r-from-python) – gene Nov 8 '13 at 12:34
  • Thank you! Despite qualms about mixing the idiosyncrasies of these two languages, rpy may be my new favorite thing ever! – user1521655 Nov 12 '13 at 15:12
5

The tool that I was looking for is the rpy extension of Python, which permits execution of R commands from the Python console.

Gene provided some useful suggestions in the previous answer, and then suggested rpy in response to my further questions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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