Scripting with R

Thanks to its official “R Console” plugin, OrbisGIS is able to execute instructions written in R language.

To see how to install this plugin, you are invited to consult this page or just check for “R console” in the Plugins manager.

The “R console” is based on Renjin. Renjin is a JVM-based interpreter for the R language for statistical computing.

R console

Here, the user is able to:

  • Write & execute ( Execute SQL instruction icon ) instructions,
  • Execute only selected instructions ( Execute Selected SQL instruction icon :width: 16 pt ),
  • Load & Save .r files,
  • Search & Replace words (with advanced options) ( Search icon ),

Use cases

List tables stored in the default H2GIS database

In this example, we are using R to list available tables imported in OrbisGIS (assuming you are in H2GIS mode).

1
2
 library(RH2GIS)
 print(dbListTables(con))

The result is displayed in the Output Console:

[1] "COMMUNE"                "SPATIAL_REF_SYS"        "TRONCON_HYDROGRAPHIQUE"
[4] "TRONCON_ROUTE"          "ZONE_OCCUPATION_SOL"
R console