How To Use ArcGIS API for Python and Jupyter Notebooks

3
228

We are so excited to show you a whole new way of working with ArcGIS. We will be using Python for GIS to perform some spatial analysis content management and GIS administration. Just using a simple and expressive language that every one of you can understand and use, not just the developers only. While the Python API can be used wherever Python runs, it shines in the Jupyter Notebook.

Also, check out this list of best Python books for beginners and experts.

The Jupyter Notebook is an open-source browser-based application. It lets you create and share these documents that can contain live code visualizations, explanatory text, and now maps using ArcGIS.

Read the latest Python tutorial – How To Send Email Using Python With Attachments.

How to use ArcGIS API for Python and Jupyter Notebooks

Getting Started with ArcGIS in a Notebook

So let’s see ArcGIS in a notebook you can make notes. You can use that for narrative, telling your story, you can type in Python code and math expressions to see the results interactively. You just brought in the ArcGIS API in this notebook you can begin using it, and you’ve logged onto your GIS. GIS could be ArcGIS Online or ArcGIS Enterprise, and in three lines of code, you’ve brought in a live map of the place you have selected.

First NOTEBOOK

How cool is that?

first python notebook

Let’s bring in some content! Suppose you were searching for your learn ArcGIS online organization for content related to your selected area and displaying the results that you get back. Looking at the results, you can see that the first layer is a layer of places in your selected area. The second result is a layer of trolley stations and creating a new map zooming in this time and adding the layers on that map.

GIS content research

Now your map has layers! You want to do some analysis, or you want to visit some of these places, and for that, you can call to create. Drive-Time Areas tool with the travel mode of walking, to identify locations within five minutes of walking distance. Those trolley stations are then overlaying the layers of places to see in your selected area with those walkable areas. That gives me a shortlist of sites that are within walking distance from the trolley stations.

shortlist of sites that are within walking distance from the trolley stations

You could take the trolley to see those places. You’ll get back your results as a layer, and you want to be able to query them as a table and visualize them on a map. One of the beautiful things done is that it is integrated this API with pandas. For those of you who don’t know, pandas are pythons library for data access. It’s like bringing excel in your notebook. You can also visualize the results, adding it to a map. That was a quick tour of getting started.

finding walkable distances in ArcGIS

  • You can do so much more, and these notebooks are great for sharing.
  • You know collaborating with others, sharing your analysis with others.

 

Second NOTEBOOK

second ArcGIS notebook

Let’s take a look at a second notebook that has an analysis on finding the best places to go running in the area you have selected. In the mornings, you like to go out for a run, and it feels great if it’s a place with low elevation, flattering, you can run hills, and it’s out in nature, that’s the most important thing.

ArcGIS - finding best places to run

Let’s look at the Python code to solve this problem. Notice how we waited for overlay analysis, which is not complex code; it’s a simple math expression that’s about as easy to understand. Map algebra for the Web GIS, and now with distributed raster analysis, it’s more potent than ever. You can do interactive raster processing right within Jupyter notebook, and see the results inline in real-time. You can add the results to a map, and this is using dynamic image processing. If you want to, you can also save the results out as a new imagery layer using an image server.

Third NOTEBOOK

Next, let’s look at a third notebook and a different kind of use. This notebook helped you to make your boss happy another day, so when he came in on a Friday evening and wanted you to configure a new ArcGIS Enterprise. Customize the home page to match your organization, add all the users from your division to the appropriate groups for collaboration, and also have the enterprise-ready to go with content. The workflow will look like; you were there to do it manually. Maybe you might have to stay back late on Friday and hopefully not come in on Saturday, but since it’s a workflow that you may need to repeat often, you can also make a script for it.

ArcGIS Enterprise workflow

It’s not complicated, and all you need to do is click run all, and the notebook will do everything for you. We’ve seen how we use these notebooks on the Python API to do some powerful analytics and GIS administration using a straightforward, expressive language.

Machine-Learning Libraries and Python

Next, let’s see the fantastic things that you can do by combining ArcGIS with the rich set of data science and machine learning libraries and Python. We want to share how we can enhance the experience of Jupyter Notebook by adding Open Python components, like an image library, and invoking IBM Watson’s deep learning.

Machine-Learning Libraries and Python

Georgia Power performs inspections of their transmission lines from helicopters, and they look for things like insulators that are broken, or contaminated, or flash. Now an inspection flight generates thousands of Geotag images, and these are just a small sample here, but when we get the data set like that, the first thing we want to do is to draw it on the map.

ArcGIS - geotag images

Here, we will be using an image library to extract the spatial location of an image and using the API. We can now turn it into a feature on a layer on a map using the address API for Python. You will love how easily it can integrate all that in the Jupyter notebook, and the experience is so secure. But what we are more excited about is the following. What you see here is just one mile out of one flight, and in that one mile, there are 400 images.

deep learning system (visual recognizer)

Now Georgia Power has over 17,000 miles of transmission lines that means today they are manually classifying over 100 thousand images. It is a daunting task. There has to be a better way to do this, and that is Deep Learning. We’ve trained IBM Watson to recognize broken insulators and images. In such a way that now, by using the Watson API, we can easily pass pixels of a brand new geotagged image into Deep Learning visual recognition system. And it will come back with the classification of damage or not.

We can take that information now and turn it into a feature layer, but what’s exciting here is we’re going to see it all in action, and what we’re going to be doing here is dynamically invoking the API. As Watson recognizes broken insulators, we can highlight them in red in here.

Watson recognizes broken insulators

So let’s see the image, Awesome! Great job here, and if we look at it here again, even in blurred images, which is very cool. So what we’ve done here a combination of Python modules, like the image library, to extract spatial coordinates from images. We automated the future identification using Watson Deep Learning, and we combine all that with the ArcGIS to gain us a deeper understanding and to enable us to do further analysis like emerging hotspots or create the third workflow in maximum.

Also Check: