Selecting Your Snake: ArcPy and the ArcGIS for Python API

Why Choose Python?

Python is a stable and versatile language, allowing complex calculations and analysis to be developed and executed with ease. This brings no questions as to why it is the standard development language when working in ArcGIS Pro. It allows ArcGIS to run ArcPy behind the scenes for ArcGIS Pro and creates easy integration with other applications that utilize its functions. It’s this very reason why we would like to discuss the key differences between ArcGIS’s complimentary libraries ArcPy and ArcGIS API for Python.

Why Does ArcGIS Have Two Libraries for Development in Python?

These differences become apparent once you have a foundation for each library’s use case. Listed below are these libraries’ functionality and respected use case:

ArcGIS ArcPy

ArcGIS ArcPy is the standard library for utilizing desktop GIS for a variety of computing purposes. It allows extensive geoprocessing, analysis, and calculations to be performed within a local python environment, bringing all the necessary tools to your GIS application or script.

Here we have a sample python script using ArcPy to create local data. The script grabs a single feature from ArcGIS’s sample server for census data and exports it into a shapefile.

ArcGIS API for Python

ArcGIS API for Python is the standard library for utilizing web-based GIS. It is designed to work directly with ArcGIS Online or ArcGIS Enterprise for tasks such as publishing, editing, and sharing. Below we build on the ArcPy script with a script using the ArcGIS API for Python library.

This script logs into the ArcGIS portal and publishes the shapefile from the previous script as a hosted feature layer. When publishing, metadata can be added directly with this library as well.

So, you see, ArcGIS’s ArcPy and API for Python both serve their individual purposes when it comes to GIS development. Each library will focus on its capabilities and offer better efficiency when conducting different operations.

Which to Use?

Depending on your application or script needs, you’ll select the library that will handle your required functionality. If you find yourself doing heavy analysis and calculations and overall using ArcGIS Pro computations, then you may want to choose ArcPy. If you find yourself doing portal configuration or item detailing and sharing, then you may want to choose ArcGIS API for Python. Both libraries can be integrated together to get an even greater control on manipulation in both local and web environments.

Have questions about ArcPy or the ArcGIS API for Python? Let us know on Twitter or via e-mail. Want to hear more from GEO Jobe? Check out these articles below:

Image of Christian "Chris" Patton smiling at the camera. He is standing in front of a lush, green background. He is a young, African-American man with glasses.

Director of Professional Services