Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
img
src/main
README.md
pom.xml

README.md

R Console plugin

Introduction

The "R console" makes R available to use in OrbisGIS. "R console" is based on Renjin. Renjin is a JVM-based interpreter for the R language for statistical computing.

Install

To install the "R console", please use at least the OrbisGIS 5.1.X version.

Then, go to the menu "Tools/Manage plugins" and search "R console" and press "Download & Start".

Go to the menu "Windows" and check the "R console".

R console installed

Implementation

"R console" is able to interact with the current OrbisGIS database, thanks to Renjin-DBI package. Renjin-DBI (R-DBI) offers various database interfaces including RPostgreSQL and RH2GIS. To facilitate the connection between OrbisGIS database and the Renjin script engine (that executes the R code), a variable named con is pushed to the ScriptEngine instance. The con variable is a java.sql.Connection wrapped as a R ExternalPtr (See Pushing data from Java to R).

The R console used a specific OSGI bundle named r-engine and build by the OrbisGIS team. You might have a shifted version compared to the master repository of Renjin. We are doing our best to keep it updated but if you need a newer version, feel free to contribute with us or the Renjin team to improve that.

In actions

How to list the tables available from the default H2GIS database ?

Execute

# Load the DBI package
library(RH2GIS)
print(dbListTables(con))
# con is the java.sql.Connection  wrapped as R ExternalPtr
# the print trace is displayed in the OrbisGIS output window.

List tables

How to use a single spatial function ?

Execute

library(RH2GIS)
data_area <- dbGetQuery(con, "SELECT ST_AREA(THE_GEOM) AS AREA FROM BUILDINGS_MAPUCE;")
print(summary(data_area))

Result

      AREA          
 Min.   :     0,22  
 1st Qu.:   69,175  
 Median :  103,865  
 Mean   :  193,214  
 3rd Qu.:   149,11  
 Max.   :43323,395  

Important

The OrbisGIS R console is based on the Renjin interpreter.

And feel free to contribute & support Renjin or OrbisGIS ecosystem in whatever manner you choose (donation, PR, documentation, feed-backs...)

Acknowledgements

We would like to thank