R Console plugin
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" 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.
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.
How to list the tables available from the default H2GIS database ?
# 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.
How to use a single spatial function ?
library(RH2GIS) data_area <- dbGetQuery(con, "SELECT ST_AREA(THE_GEOM) AS AREA FROM BUILDINGS_MAPUCE;") print(summary(data_area))
AREA Min. : 0,22 1st Qu.: 69,175 Median : 103,865 Mean : 193,214 3rd Qu.: 149,11 Max. :43323,395
The OrbisGIS R console is based on the Renjin interpreter.
- To known the list of supported R packages, please consult http://packages.renjin.org/
- If you need help on Renjin, go to the renjin-dev mailing list
- If you need specific development on Renjin, please contact email@example.com
- If you have any questions about geospatial data, processing, please contact firstname.lastname@example.org
And feel free to contribute & support Renjin or OrbisGIS ecosystem in whatever manner you choose (donation, PR, documentation, feed-backs...)
We would like to thank