Permission
Make sure you have gained the access to the Plugin panel and gained permission to add a new plugin, please read the “Prerequisites for Plugin Development – Digitwin Documentation Base” documentation” first.
R Script Development
You can follow the example of “sample_greenarea.r” or other existing examples in the repo to develop your own plugin. A few tips are given below:
- You may need to set your default working directory to your local directory which hosts the plugin repo when doing the local testing so that “utils.R” can be successfully loaded. (e.g., setwd(“C:\\Users\\John\\dt-plugin-r”))
- Make sure your function parameters are in a consistent order. It is important to have the same order when configuring your plugin in the Digital Twin (DT) afterwards.
- You need to get the “jobInfo” value from “Plugin Explorer” -> “Get Params” in DT for your local testing (see image below). The jobInfo includes the case area information that is being loaded in the DT. If the case area is switched, make sure the updated “jobInfo” is loaded in R.

- The outputs will include at least one of the following in JSON format, add them according to the plugin’s need (also see “Output result support type – Digitwin Documentation Base“):
Output | Description |
geolayers | The wms layer generated from the plugin and published to the GeoServer. |
tables | The table generated from the plugin that can show data in a table format. |
charts | The chart generated from the plugin to visualise the data. These types of charts are supported, please see “sample_greenarea.r” for example usage: columnchart/barchart, linechart, areachart, radarchart, piechart, donutchart, scatterchart. |
textlines | Text lines generated from the plugin to be displayed in the result dialog. |
message | Message is used to capture error information and is printed in the console. |
- It is always a good practice to well document your script before publishing.
Add Plugin to Digital Twin
Once the plugin is ready to be published, make sure “setwd” has been set to the default “setwd(LocationOfThisScript())”, “jobInfo” is clean, and parameters are in a consistent order. You also need to make sure the libraries you are using in the plugin script exist in our DT R libraries. If not, you can search and add the libraries in the “Plugin Explorer” -> “R Libraries” (see image below).

To add a new plugin, just click the “plus button” in “Plugin Explorer” -> “My Plugin”. Then fill in all the necessary information in the pop-up window and upload your R script. Please make sure all the parameters are in the correct order as they are in the R script. Do not add “jobInfo” parameter in the parameters because it will be automatically added. To create a new version, in “My Plugin“, click “More Options” -> “Create New Version”.

Once the new plugin is added or a new version is created, our admin will review the plugin, and either approve or reject it with our comments. If there has already been an older version in use, the older version will not be affected until the new version is approved. If your plugin is available, you can also activate or deactive it, and assign access to certain user groups through “Access Control” in “My Plugin” -> plugin’s “More Options”. This will decide whether your plugin can be found in “All Plugins” for certain user groups.
If your plugin has been approved, it can be installed from “All Plugins”, and the installed plugins can also be uninstalled.
Enjoy developing your plugins and exploring other plugins!