Introducing the R-ArcGIS Bridge

by | Jul 11, 2016

Bringing together the user communities of R and ArcGIS was the motivation behind the release of the R-ArcGIS bridge software package last year. This blog post discusses how GIS can incorporate the R language and enhance geospatial workflows.

By Eric van Rees

What is R?

The R Project for Statistical Computing , or simply named R, is a free software environment for statistical computing and graphics. It is also a programming language that is widely used among statisticians and data miners for developing statistical software and data analysis. Over the last few years, they were joined by enterprises who discovered the potential of R, as well as technology vendors that offer R support or R-based products.

Although there are other programming languages for handling statistics, R has become the de facto language of statistical routines, offering a package repository with over 6400 problem-solving packages. It is also offers versatile and powerful plotting. It also has the advantage of treating tabular and multi-dimensional data as a labeled, indexed series of observations. This is a game changer over typical software which is just doing 2D layout, like Excel.

What is the R-ArcGIS bridge?

The R-ArcGIS bridge is a free, open source R package that connects ArcGIS and R. It was released together with an R ArcGIS community website on GitHub, encouraging collaboration between the two communities. The package serves three purposes: ArcGIS developers can now create custom tools and toolboxes that integrate ArcGIS and R, ArcGIS users can access R code through geoprocessing scripts, while R users can access organizations GIS’ data managed in traditional GIS ways.

How does it work?

The package can be downloaded by following the URL underneath the blog post. Detailed installation instructions are given at the download page. It’s important to know where you can run the package: you need to have at least version 3.1 of the R software installed, along with either ArcGIS Desktop 10.3.1 or ArcGIS Pro 1.1 (or later versions of both). If you install the R software, you install both 32 and 64 versions. When using ArcGIS Pro and R, you use the 64-bit version of R. In the case of ArcGIS Desktop, you have to make sure that when you that if you are running ArcGIS Desktop from the app, you use the 32-bit version of R. If you want to use the 64-bit version of R, you can use it with the ArcGIS Desktop Background Geoprocessing product.

After installing the package, it´s possible to connect both environments. Starting from within R, you can connect to ArcGIS by loading the ArcGIS-R bridge library and initialize an connection to ArcGIS. Similar to working with data cursors in Python, there are two stages for opening GIS data if you want to work in R: first, you need to select a GIS data source (such as a feature class, layer or table). Second, you need to filter the data to the set you want to work with. The reason for this is that R runs and processes data in-memory, so an in-memory data frame is created rather than storing an entire file in-memory. This data frame retains references back to the geometry data.

In order to analysis in R with spatial data, it needs to be represented as sp objects. This conversion is done with arc.data2sp. After finishing your work in R, the results need to go back to ArcGIS, either by writing to an existing data source or a new one. The results can be written to a new feature class using the arc.write statement in R.

By building R script tools, you can run R scripts inside ArcGIS and make use of R functionality, for example by using data input from a GIS, processing it with R and having it sent back to ArcGIS without having to change from one environment to another – the script tool takes care of that. You can also put different geospatial and statistical workflows together with Model Builder in ArcGIS, for example by making an R script part of a large geospatial analysis workflow, thus making it an even more powerful methodology.

Link to the ArcGIS R community on Github: https://r-arcgis.github.io/

Categories

Recent Posts

Eric van Rees
Eric van Rees is a freelance writer and editor. His specialty is GIS technology. He has more than eight years of proven expertise in editing, writing and interviewing as editor and editor-in-chief for the international geospatial publication GeoInformatics, as well as GIS Magazine and CAD Magazine, both published in Dutch. Currently, he writes about geospatial technology for various clients, publications and blogs.

Sign up for our weekly newsletter
to receive content like this in your email box.