ArcGIS Notebooks are now integrated into ArcGIS Pro with the 2.5 release. ArcGIS Notebooks use open-source Jupyter notebook, which has been included in the ArcGIS Pro Python distribution since ArcGIS Pro 2.1. As of the ArcGIS Enterprise 10.7, ArcGIS Notebooks were also integrated into the ArcGIS Enterprise Portal with Notebook Server.
Jupyter notebooks combine cells of live Python code with narrative text and visualizations in a single document. They have become widely adopted by the data science community because they support iteratively and interactively documenting, processing, analyzing, and visualizing data in a notebook format that can be saved, shared, and used to report results.
If you would like to learn more, here are some additional resources with further details:
Check out the tutorial sections below to get started or skip ahead to the Q&A section. Feel free to leave a comment if you have any questions or feedback.
1. To get started with notebooks in Pro, open a new project and from the Insert ribbon click New Notebook.
2. After saving the notebook, open it using the Catalog pane.
3. You can arrange the notebook view so that you can see your map and notebook side-by-side.
If you'd like to see an example of how ArcGIS Notebooks and ArcGIS Pro interact, follow along with this quick tutorial as we explore the 2010 census population data for New England states. Alternatively, you may download the sample project package.
4. Make sure you are signed into ArcGIS Online or your organizational Portal, then navigate to the Portal tab on the Catalog pane, click the Living Atlas tab and search "USA States". Context-click the item named "USA States (Generalized)" and select Add To Current Map.
5. We are interested in the population of US states, so let's also open a chart. Context-click the USA_States_Generalized layer in contents and choose Create Chart > Bar Chart.
6. On the Chart Properties pane, under Category or Date, choose the Name field from the dropdown. Under Numeric field(s) check POP2010 on. Leave everything else on default and click Apply.
7. You can arrange the chart, map, and notebook views so they are all visible.
8. In the Notebook view, enter the following text into the first cell.
### New England Population and Area What are the 2010 population and area of New England?
9. Select Markdown from the dropdown list above the cell, and then press shift+enter on the keyboard to run the current cell and simultaneously create a new cell below (or select the next cell).
The cell will be formatted in markdown and the entered text becomes a header and description for your notebook. This allows you to narrate the notebook and break it into sections.
10. From the Map ribbon click the Select button and select the states Maine, Massachusetts, New Hampshire, Rhode Island, and Vermont. These states are commonly referred to as New England. Note that the states are also selected in the chart.
11. Geoprocessing operations performed in the notebook will also honor selections made in Pro. Complete steps 12-14 with the New England states still selected.
12. Enter the following code into the next cell of your notebook and press shift+enter to run it.
# Set data lyr = "USA_States_Generalized"
13. In the next cell, enter the following code and from the Cell menu of the notebook view select Run Cells And Select Below.
with arcpy.da.SearchCursor(lyr, ["POP2010", "SHAPE@"]) as rows: ne_pop = 0 geoms = arcpy.Array() for row in rows: ne_pop += row[0] geoms.append(row[1][0]) ne_geom = arcpy.Polygon(geoms)
14. In the next cell below, enter the following code and press control+enter, this will run the cell without creating a new cell below.
print(f"Population: {ne_pop:,}") print(f"Area: {ne_geom.area:,}") ne_geom
With this tutorial, you have seen how you can use ArcGIS Notebooks interactively in ArcGIS Pro by bringing 2010 State Census data into your map, exploring population attributes with a chart, and then referring to the data by layer name in your notebook and operating on a selected subset of the data to obtain a summary of the total population and area of New England states. You can also use the arcgis library to analyze data using a pandas-based spatially enabled data frame.
Q: How does the experience of running an ArcGIS Notebook in Pro differ from running a Jupyter Notebook outside of Pro?
A: With notebooks running in Pro, you can open a map view and a notebook view side-by-side, allowing you to visualize and directly interact with the emerging data, document and automate the workflow, and save it for later.
An edit session can be started by directly editing the target layer within ArcGIS Pro using the Edit ribbon, or by using arcpy.da.Editor(<workspace>) as illustrated in the following lines of code:
infc = "tl_2010_us_state10" workspace = r"path/to/data.gdb" with arcpy.da.Editor(workspace) as edit: result = arcpy.management.DeleteFeautres(infc)
Q: Can I use the standard Jupyter Notebook keyboard shortcuts?
A: Keyboard shortcuts work just like they do in the default web based Jupyter Notebook.
Q: Why can't I use magic (%) or shell (!) commands in my notebook?
A: Magic and shell commands are not currently supported when running a notebook in Pro.
Q: Why are figures from matplotlib not showing up in the cell output of my notebook?
A: Inline visualizations from matplotlib are not currently supported. You will need to use the show() method to view these. For example:
import matplotlib.pyplot as plt import pandas as pd import arcgis sedf = pd.DataFrame.spatial.from_featureclass("tl_2010_us_state10") plt.bar(sedf.State_Name, sedf.Total_Population) plt.show()
Q: I cannot find the option for restarting the kernel.
A: You currently cannot restart the kernel unless you close and reopen ArcGIS Pro. You can, however, interrupt the kernel using the "Interrupt Kernel" button from the Notebook ribbon.
Q: I'd like to use R or C# in my notebook instead of Python.
A: You can only open a Python kernel in notebooks running in ArcGIS Pro, other languages are not supported.
Q: I'd like to export my notebook (.ipynb) as a python script (.py), is that possible?
A: Yes, you can use the jupyter command nbconvert from the command prompt:
jupyter nbconvert --to script "Path\To\Your_Notebook.ipynb"
The resulting Your_Notebook.py file will be in the same directory as Your_Notebook.ipynb.
Q: Can I open a Jupyter notebook in ArcGIS Pro that I have previously created outside of Pro?
A: Yes, ArcGIS Notebooks are simply Jupyter notebooks and any .ipynb file can run in Pro, however, it is your responsibility to ensure any libraries used in these other environments are available in the active environment of ArcGIS Pro. To open an existing notebook in Pro, navigate to the folder containing the notebook(s) using the Catalog pane and either double-click to open it or context-click the notebook and choose Open Notebook.
Q: Can I use my ArcGIS Notebook created in Pro across other platforms?
A: ArcGIS Notebooks are simply Jupyter Notebooks (.ipynb) and can be run in any Jupyter environment or as hosted ArcGIS Notebooks in ArcGIS Enterprise or ArcGIS Online (currently in beta). However, it is your responsibility to make sure that any libraries used in the notebook are available in these other environments.
Q: From an ArcGIS Notebook hosted on portal I can authenticate my credentials using arcgis.GIS("home") instead of entering my username and password, why doesn't this work from my notebook in Pro?
A: If you are connected to your ArcGIS Online organization or Enterprise Deployment in your current ArcGIS Pro session, you can use arcgis.GIS("pro") instead. See the documentation on working with different authentication schemes for more details.
Q:Why can't I open a notebook in Pro from a UNC path?
A: Opening notebooks in Pro from a UNC path is currently not supported, we recommend mapping the UNC path to a drive or alternatively creating a symbolic link.
Q: Why aren't arcgis API map widgets displaying in my notebook?
A: The map widget loads the ArcGIS API for JavaScript from js.arcgis.com, which has recently enforced HSTS standards (HTTPS only). For a time, the Python API redirected to an HTTP URL that no longer functions after the update. Installing the arcgis API version 1.8.4 and greater will resolve this issue. From the Python command prompt, run:
conda install arcgis
Map widgets should now work after restarting Pro.
The installed version of the arcgis API can found with the following command:
conda list arcgis
If your map widgets still won't show, read on:
Prior to updating the arcgis API, we suggested a couple of workarounds to make sure widgets draw. If you used one of the previous workarounds, make sure to undo these.
import os
os.environ['JSAPI_CDN'] = 'https://js.arcgis.com/4.15/'
from arcgis.widgets import MapView
MapView.set_js_cdn('https://js.arcgis.com/4.15/')
Note that your link to the JS API may be different depending on the versions of the arcgis API you installed. On an older version of the arcgis API, the JS API CDN had to be set to target the correct version using the table below as a reference:
Python API Version | JS API Version |
1.8.3 | 4.15 |
1.8.2 | 4.15 |
1.8.1 | 4.15 |
1.8.0 | 4.14 |
1.7.1 | 4.13 |
1.7.0 | 4.13 |
1.6.2 | 4.11 |
1.6.1 | 4.11 |
1.6.0 | 4.10 |
1.5.2 | 4.9 |
1.5.1 | 4.8 |
1.5.0 | 4.8 |
Ex: My version of the arcgis API is 1.7.0, so the JS API url should be https://js.arcgis.com/4.13/.
Q: I keep clobbering variables when I have multiple notebooks open in Pro. Why are variables names being shared across multiple notebooks?
A: ArcGIS Pro runs a single Python instance. This execution context is shared by each notebook opened in a single instance of ArcGIS Pro. Depending on the contents of concurrently open notebooks, this could potentially result in variable name collisions. To avoid potential issues you may consider:
Thanks. A great resource through Q&A for using ArcGIS Notebooks in ArcGIS Pro 2.5.