Three Ways to Get Jupyter Notebooks and the ArcGIS API for Python

Alberto Nieto
6 min readJul 6, 2017

--

Jupyter Notebooks have become a crucial tool in the Python and Data Science communities over the past years. Their seamless integration with some of the most important Python libraries and their interesting structure that encourages efficient prototyping and visualization have made Jupyter Notebooks one of my favorite tools as a Python user.

With the new ArcGIS API for Python, GIS users can now also use this tool and integrate all of its benefits with a distributed GIS. The possibilities are quite exciting!

… but how do I get a Jupyter Notebook running on my machine?

If you’re ready to start exploring, there’s a few paths you can take to install and open your first notebook. The following are three easy, recommended ways to get Jupyter Notebooks running on your system:

1. Try the API in a live sandbox

The simplest and quickest way to start writing your first Jupyter Notebook is to use the live ArcGIS API for Python sandbox at notebooks.esri.com. This approach doesn’t install anything on your system and operates nicely as a test environment to let you get started with your first notebook.

Once you navigate there, you will see a simple page with a few tabs, icons, and items. Opening your first notebook is as easy as selecting the “New▼” button and selecting “Python 3” from the drop-down menu.

Voila! You’re ready to start writing.

This option is very useful to start writing notebooks from any system that has an internet connection. With this approach, nothing installs locally and you can get started in just seconds.

However, this live sandbox environment does not save your user session and will reset if you reload your browser page, which raises an important caveat to keep in mind when trying this approach:

If you wish to save your notebook beyond a single session, you will need to download the notebook to your system.

Thankfully, saving a notebook is easy as pie. Select the File tab, then Download as, then Notebook (.ipynb):

Hot tip: You may have noticed the other options when selecting a download format, including as a Python (.py) file and HTML (.html).

I find the option to download as a Python (.py) file useful when enough progress is made in the testing and prototyping stage of writing code and you are ready to take the scripted process or functionality into production. Downloading as an HTML (.html) file is also very useful when embedding a static snapshot of your notebook into another webpage.

Once you test a few notebooks using the live sandbox and get a feeling for how the entire tool operates, I recommend that you take the next steps to install the tool locally with one of the following options:

2. Install using the ArcGIS Pro Python Package Manager

If you have ArcGIS Pro 1.4 or later installed, you can use its Python Package Manager to install and manage the ArcGIS Python API, making the procedure extremely simple and GUI-driven.

From ArcGIS Pro, select the Project tab at the top-left of the application, select Python from the menu options in the left, then select Add Packages and enter “arcgis” to find the ArcGIS API for Python:

Installing Using the Python Package Manager in ArcGIS Pro

The package manager installs everything it needs and also allows you to manage updates or uninstalls (who would do such a thing?) of the API through the interface.

Another hot tip: Take a second to explore other Python packages available through this Package Manager and test out a few, such as the r-arcgisbinding package.

3. Install Jupyter Notebooks and the API Using Anaconda

The ArcGIS API for Python can also be installed using conda, a package manager that comes as part of the Anaconda for Python distribution (just make sure you get the Python 3x installer).

Anaconda is a fairly heavy distribution but the benefits are significant: with one installation you receive access to more than 100 of the most-used Python packages for data science and a wealth of other capabilities to use with your Jupyter Notebooks. For instance, the requests module that comes with Anaconda is an excellent way to work with Python and HTTP requests.

Once you have Anaconda for Python 3x installed, you gain access to Jupyter Notebooks. Finalizing the installation for the ArcGIS API for Python is then as easy as entering the following in a terminal or command prompt:

conda install -c esri arcgis

Once the package is fully installed the fun begins!

Opening your First Notebook Using a Local Installation

Once you have Jupyter Notebooks and the ArcGIS API for Python locally installed in your system, creating your first notebook is as simple as opening up a new terminal or command prompt and entering the following command:

jupyter notebook

Any jupyter notebooks you create after this point are saved at the location where the terminal or command prompt opened your jupyter notebook, so remember to change directories (cd) to the location where you want to save your notebooks!

Final hot tip: If you’re using Windows and don’t often use the command prompt, a quick way to open up a command prompt window in a specified path is to select the address bar at the top of the Windows Explorer window and enter “cmd”.

Now that you have installed Jupyter Notebooks and the ArcGIS API for Python and opened up your first notebook, it’s time to test by creating your first reference to a GIS and your first map.

Create a new cell and enter the following Python code:

from arcgis.gis import GIS

my_gis = GIS()

my_gis.map()

A dynamic, controllable map loads beneath the cell. Save this notebook as “Hello Map” and frame it on a wall or stick it to your fridge. We are now ready to go explore!

With installation and your first notebook out of the way, you are ready to test, prototype, map, analyze and create with all the potential that the tool provides.

A few tips are recommended as you start getting acquainted with this tool, and an excellent, detailed guide is available as part of the ArcGIS API for Python documentation. You may also take a look at the sample notebooks to get started with robust GIS integration.

Once you’ve created a few notebooks to handle basic workflows, come back and we’ll discuss a few approaches to start integrating functionality between the API, Pandas, and other interesting approaches that benefit from the functionality in Jupyter Notebooks and the ArcGIS API for Python. Stay tuned!

--

--

Alberto Nieto

Exploring and learning about using Geography and Software to solve problems.