At present most GIS software, including ArcGIS, QGIS, GRASS and other industrial applications as well as open source, use Python as scripting language and complement for plugins. This language is also used for programming needs that can increase the spatial analysis functions and the spatial processing.

In the follow up of this logic, a recent integration of the statistic R package was performed to use in QGIS. The users can access to the library of Space R analysis (increasingly used) in the processing panel.

Although R is essentially a set of statistics, its use has been extended to a number of areas, such as natural language processing. This library also features strong tools for spatial analysis, including point distributions analysis and Bayesian modelling geostatistics. It can read and manage a variety of vector and raster data, including shape files, NetCDF and GDAL.

Traditional GIS programs are, often, limited by their spatial statistics and analysis capacity were relatively trivial, including a small range of integrated functions, forcing users to use other platforms for advanced analysis, modelling and simulation. ESRI has highlighted this imperfection by acquiring the MapStudio program from the University of Minsk, which became from 2001 the ArcGIS Geostatistical Analyst extension.

Using R, many popular statistical proceedings and more advanced analyses, including a variety of simulation applications, can be applied directly in tools such as QGIS.

Installing of R for QGis.

No need of you to rush to the QGis processing panel to find R. It is not part of the processing providers provided with the installation of QGis.

You must download and install R on your computer before setting QGis to be able use it.

To download R, this is the right link: https://cran.r-project.org/bin/windows/base/

Once downloaded, double click on the file R-3.3.2-win.exe to install R on your computer.

The program installs R in the directory C: \ Program Files \ R \ R-3.3.2

 

Configuring QGis treatment options

 

To configure R, open the window Options treatments (treatments -> Options …)

Deploy  the item Treatment providers -> R scripts

Check the Activate box to activate option R and it appears in the panel Treatments.

If you have a 64bits Windows version, you can check the box Use the 64-bit version. If you have a 32-bit post, only the 32-bit version of R is installed. If you have a 64-bit extension, both versions (32 and 64 bits) are installed. If you do not check the box you will use the same 32-bit version even if your PC is a 64 bit.

You have to configure the directory with the R library for QGis. This directory, rlibs is located in C: / User / your username /.qgis2/processing

If it does not exist, create a directory rscripts besides rlibs and indicate this repertoire as Scripts Directory R.

Point the R directory to the installation directory, by default C: \ Program Files \ R \ R-3.3.2

Click OK to close the Treatments Options window.

Now you have the provider R that appears in the treatment panel, with two sub-items:

The first Create new R script opens an editing window or you can type a Python script. If you have entries to be set for the execution to do it.

The second, Get R scripts from on-line scripts collection, allows you to use Python scripts ready to use with the adequate processing windows already configured.

Let’s see an example. You want to perform a histogram R of a field of a vector layer.

Double- click on Get R scripts from on-line scripts collection to open the window Get scripts and templates:

Open item Not installed:

Search the tool Histogram, select and click OK.

In the 2.18.2 version that I use, the treatments window will not update immediately. If you open again the window Get scripts and templates you will see a new item in Update available (in the case of the histogram) or under the item Installed.

When you close again this window , the R treatments window in the treatments panel is updated and your new tool is now available under User R script -> Histogram

If you double click on the tool, the settings window will open:

When you click Run , the treatment is carried out :

If you are not familiar with R, this is the easiest way to start using the tools R offers.

If you make a right click on the treatment tool of the panel, you can select the option Edit the script to see the construction of the Python script:

There it is! We have partially opened the door for you to discover the possibilities that R can offer you .

 

 

 

Si cet article vous a intéressé et que vous pensez qu'il pourrait bénéficier à d'autres personnes, n'hésitez pas à le partager sur vos réseaux sociaux en utilisant les boutons ci-dessous. Votre partage est apprécié !

Leave a Reply

Your email address will not be published. Required fields are marked *