ArcGIS Pro

R Notebooks in ArcGIS Pro for Spatial Data Science

Have you ever marveled at maps, charts and insights from a fellow analyst’s work and wanted to apply the same workflow on your data? If your answer is yes, you are not alone. As methods and and workflows to tackle complex problems become more available, repeatability and reproducibility of workflows take center stage.

Importance of sharing and the ability to repeat workflows are resonating in every discipline, ranging from natural sciences to data science. The need to share and repeat analytical work is of paramount importance to enable “digital resilience” (Wright, 2016) through sharing data and analysis freely.

There are many ways to share your analysis within the ArcGIS platform, from the visual programming experience of ModelBuilder to Python notebooks for portal and local Jupyter notebooks.

When your work integrates R packages and workflows within ArcGIS, an R (Jupyter) notebook is an easy way to share your analysis and your work . Jupyter notebooks enable sharing live code with a wide audience, build large analysis pipelines and facilitate contributing to open source projects and public knowledge-base. In this blog, we will explore how you can design, create and share sophisticated workflows when using the R language in ArcGIS Pro.

R-Notebooks: What are they and why should you care?

R notebooks, giving Jupyter its last letter, are first class citizens of Jupyter notebook ecosystem. They allow sharing and documenting R analysis with a broader audience of scientists, analysts and developers by providing a platform to visually inspect and interact with R code.

ArcGIS platform supports Jupyter notebooks that helps you prototype, share and extend your spatial analysis. Even though general rules of Jupyter notebooks apply to R Notebooks in terms of code etiquette and what you can use them for, R notebooks opens up vast scientific R libraries within the Jupyter ecosystem. What does this mean for us who live and breathe spatial analysis? Enter R-notebooks in ArcGIS Pro.

R-Notebooks in ArcGIS

ArcGIS Pro is fully connected with R language through the R-ArcGIS Bridge. R-ArcGIS Bridge, or as we call it “The Bridge”, is an R-package called arcgisbinding that allows moving spatial and spatio-temporal data from ArcGIS ecosystem into R ecosystem. It has been an enabler for spatial data science for more than 26,000 users (and counting) since its inception.

ArcGIS Pro’s Conda integration allows creating Conda environments that can be configured to contain R packages alongside Python libraries that ArcGIS Pro ships with and more. Currently, Conda includes more than 80 of the most popular R packages, for the laundry list of all the R packages available through Conda visit this link. We bundled some of the essential R packages in a Conda package titled r-arcgis-essentials. In the following sections of blog, we will walk through how to use this Conda package to setup an R friendly environment and also how to access R notebooks that reside in this environment.

How to Get Setup with R Notebooks with ArcGIS Pro?

Getting set up with R notebooks is easy with ArcGIS Pro’s Python package manager. Python package manager can create a clone of the Conda environment ArcGIS Pro ships with, arcgispro-py3. Once the clone that contains all libraries that power ArcGIS Pro is created, you can add libraries that enable R Notebooks such as IR-Kernel. Below are some quick steps that will help you easily get setup with R Notebooks in ArcGIS:

1-) Create a clone (Conda environment) of the arcgispro-py3 environment
2-) Switch to the new Conda environment
3-) Restart ArcGIS Pro
4-) Install Conda packages that you need for R Notebooks

Step 4 can be very challenging if you are not an expert in resolving dependencies and creating Conda environments that contain both R and Python can be tricky. For this reason we create a few custom Conda packages that will get you started with minimal effort. As mentioned before, r-arcgis-essentials, contains only the essentials of so that you can perform spatial analysis in R and also use R Notebooks for your analysis. Another Conda package is space-time-learn-lesson that contains R notebooks and R packages created for a learn lesson that work on spatio-temporal data. Below is an birds-eye-view of how you can create a Conda environment for R notebooks from scratch by using one of these custom Conda packages:

Once you have a Conda environment that contains libraries to power R notebooks, you can launch R Notebooks to start analyzing, creating and sharing. In this blog, we will explore Jupyter Lab as it helps you manage different notebooks, consoles and allows you to harness the full power of Jupyter ecosystem.

Below are steps you need to follow to get started on your first R Notebook. Note that our Conda environment already contains the R-ArcGIS Bridge and it also automatically installs R.

In this blog, we explored how to get setup in R notebooks and how to utilize them efficiently with Jupyter Lab. R Notebooks in ArcGIS Pro unlocks your analysis and makes it visible, presentable and transparent. It allows you contribute to your own analysis ecosystem and let’s you efficiently share your workflows.

If you would like a deep dive into integrating R Notebooks in your spatial analysis check out this recent learn lesson that walks you through integrating R notebooks in your spatial analysis.

If you are interested in seeing what you can do with these notebooks and the R-ArcGIS Bridge, come see us next week at the UC, where we will showcase analysis on R notebooks in multiple sessions (session 1 and session 2) for advanced spatial analysis, integrating Pyton workflows in R, interactive mapping and more.

About the author

Orhun Aydin

Orhun is a researcher and a product engineer for the Spatial Statistics team. He is passionate about developing methods that incorporate "the where" to understand "the why".

Next Article

Build a Heat Index Map in 5 Minutes

Read this article