ArcGIS Notebooks in ArcGIS Pro (2.8) FAQ

1418
0
05-19-2021 11:27 AM

ArcGIS Notebooks in ArcGIS Pro (2.8) FAQ

ArcGIS Notebooks are based on the open-sourceJupyter notebook, which has been included in the ArcGIS Pro Python distribution since ArcGIS Pro 2.1. Since Pro 2.5, notebooks can run directly in ArcGIS Pro allowing a side-by-side view of your map and notebook and for direct interactions with the data on your map. 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. See theArcGIS Notebookslanding page to learn more about notebooks across Esri products.

With ArcGIS Pro 2.8, there are several updates that improve your experience, including the following:

  • The default position of the first notebook in a project can be customized with theUser Interface options
  • 笔记本带选项卡包含一个新的按钮exporting a notebook to a Python (.py) or HTML (.html) file.

To learn more about notebooks in Pro, see these links:

常见问题s

Q: How does the experience of running an ArcGIS Notebook in ArcGIS Pro compare with running a Jupyter Notebook outside of Pro?

A:With notebooks in ArcGIS Pro, you can open a map view and a notebook view side-by-side, allowing you to visualize and directly interact with the data.

  • Layers and other contents of your map can be accessed in your notebook by name. You can access data that is not currently in your table of contents using the full path to the data. Note that dragging and dropping an item from the contents pane into the notebook is currently not supported.
  • If you have selected data in the map view, geoprocessing tools running from the notebook honor the selections.
  • Global geoprocessing environment settings are respected and can be overridden by environment settings set from the notebook.
  • The output of geoprocessing tools is added to the active map by default.
  • When a notebook view is active, the Notebook ribbon will appear. From here, you can create a new notebook, save the current notebook, or interrupt the kernel.
  • The result of running a geoprocessing tool from the notebook will be logged in the geoprocessing history.
  • Geoprocessing workflows can occur during an ongoing editing session. If a geoprocessing tool modifies a feature being edited in an edit session (it does not save the result of geoprocessing as another feature class), you can save or discard the modifications from the Edit ribbon. Note that the Map view must be active in order for the Edit ribbon to be accessible.

Q: Can I use the standard Jupyter Notebook keyboard shortcuts?

A:Keyboard shortcuts work just like they do in Jupyter Notebook.

Q: Can I use magic (%) and shell (!) commands in my notebook?

A:Yes! Many magic and shell commands are supported since ArcGIS Pro 2.6. Magic and shell commands are a convenience that enhance data analysis and offer a bridge for executing shell commands without leaving your notebook. Certain magic and shell commands are currently unsupported, including but not limited to%的历史,!ipconfig, and!ping

For more information regarding magic and shell commands, seemagic commandsandshell commands

Q: Why are figures from matplotlib not showing up in the cell output of my notebook?

A:Inline visualizations frommatplotlibare supported since ArcGIS Pro 2.6. You will need to use thematplotlib.pyplot.showmethod to view these. For example:

%matplotlib inline # Imports import matplotlib.pyplot as plt import pandas as pd import arcgis # Create spatially enabled data frame (SEDF) sedf = pd.DataFrame.spatial.from_featureclass("USA_States_Generalized") # Create plot plt.bar(sedf.STATE_NAME, sedf.POP2010) # Update plot elements plt.suptitle("Population of New England States", fontsize=16) plt.ylabel("Population (in millions)") plt.xticks(rotation=45) # Draw the plot plt.show()

Q: Where can I 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 on the Notebookribbon.

Q: Can I 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) to a Python script (.py), is that possible?

A:Yes, new in ArcGIS Pro 2.8, you can now export notebook to a Python (.py) or HTML (.html) file from the Notebook ribbon’s Export button.

you can also use the Jupyter commandnbconvertfrom the command prompt, or you can run the command directly from your notebook by preceding the command with an exclamation mark (!).

!jupyter nbconvert --to script "Path\To\Your_Notebook.ipynb"

The resultingYour_Notebook.pyfile will be in the same directory as your notebook,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 notebook can be run in ArcGIS Pro. However, it is your responsibility to ensure any libraries used in these other environments are available in the active environment of ArcGIS Pro.

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. However, it is your responsibility to make sure that any libraries used in the notebook are available in these other environments.

  • Using Notebooks hosted on Enterprise Portal in ArcGIS Pro: There are several options for moving a hosted notebook to your local machine.
    • Make sure you are signed into a portal. From theCatalogpane in ArcGIS Pro, go toPortal > My Content, right-click a notebook item, and selectDownloadHannesZiegler_0-1621447997964.png

    • Signed into Portal on the web browser. From theNotebook Editorin Portal, on notebook menu ribbon, clickFile> Download as > notebook (.ipynb)HannesZiegler_1-1621447997973.png

    • Signed into Portal on the web browser. From the notebook'sItem Detailspage (accessible from theContenttab by clicking on a notebook item), clickDownloadto download the notebook in.ipynbformat.HannesZiegler_2-1621447997979.png

  • Using Notebooks created in Pro on my Enterprise Portal:
    • You can upload any notebook file (.ipynb) to your portal. Sign into your organization's Portal from the browser, go to theContenttab of the contents page, clickAdd Item > From your computerand chooseFrom my computer.From theAdd an item from my computerdialog, clickChoose Fileand browse to a notebook file on your computer, provide a title and tags, and then clickAdd Item

HannesZiegler_3-1621447997986.png

Q: From an ArcGIS Notebook hosted on portal I can authenticate my credentials usingarcgis.GIS("home")instead of entering my username and password, why doesn't this work from my notebook in Pro?

A:In ArcGIS Pro 2.5, you had to usearcgis.GIS("pro")instead ofarcgis.GIS("home").自ArcGIS Pro 2.6,只要你连接ed to your ArcGIS Online organization or Enterprise Deployment in your current ArcGIS Pro session, you can usearcgis.GIS("home").Learn more about working with different authentication schemesdifferent authentication schemes

Q: I have seen collapsible headings in ArcGIS Notebooks on Notebook Server. Can I use collapsible headings with notebooks in Pro?

A:Yes, collapsible headings are enabled since ArcGIS Pro 2.7.

Q: When opening a notebook in ArcGIS Pro, why did I receive a "Failed to load notebook" error?

A:If you have made any changes to the Jupyter configuration filejupyter_notebook_config.py, make sure you haven't modified thec.NotebookApp.iporc.NotebookApp.portconfiguration options, as modifying these will prevent ArcGIS Pro from launching the notebook.

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 alternativelycreating a symbolic link

Q: I keep clobbering variables when I have multiple notebooks open in Pro. Why are variable 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:

  1. Using unique variable names across all concurrently running notebooks
  2. Running the%reset -f magiccommand as needed to delete all the variables in the namespace

Version history
Last update:
‎10-25-202109:04 AM
Updated by:
Contributors