Table of Contents
The Video
Introduction
Are you scripting against ArcGIS Online or ArcGIS Enterprise Portal? In the video above, you will learn how to programmatically detect whether your ArcGIS API for Python script is running against Portal or ArcGIS Online and why this distinction matters for real-world GIS automation.
Automate ArcGIS Online Feature Service Workflows with the ArcGIS API for Python | A Complete Guide from Beginner to Advanced | Full Course
Free on YouTube! A set of videos detailing ArcGIS Online Feature Services workflows using the ArcGIS API for Python. We will do a deep dive into properties and methods available, along with custom workflows for automating with Feature Services and the ArcGIS API for Python.
arcgis modules
The API provides access to your organisations ArcGIS Online via the GIS class in the gis module. This GIS class is the gateway to ArcGIS Online and properties about the GIS that you are accessing.
## provides access to ArcGIS Online
from arcgis.gis import GIS
Accessing ArcGIS Online
GIS class. There are a handful of ways to achieve access, if you are logged into your ArcGIS Online in ArcGIS Pro you can simply use "home", otherwise, another common way is to provide the ArcGIS Online URL, followed by your username and password.
## Access AGOL
gis = GIS("home")
## Access AGOL
gis = GIS(
url = "https://your_organisation.maps.arcgis.com/",
username = "Your_Username",
password = "Your_Password"
)
Are we accessing a Portal
GIS object has a property called properties that exposes the property isPortal. The isPortal property will return True if we are accessing an Enterprise Portal or False if we are accessing ArcGIS Online.
## Check if you are accessing a Portal
if gis.properties.isPortal:
## inside a Portal
print("Portal")
Otherwise we are accessing ArcGIS Online
isPortal is False, then we are accessing ArcGIS Online
## Otherwise you are accessing ArcGIS Online
else:
## inside AGOL
print("AGOL")
Geospatial Professionals, GIS Analysts, and enthusiasts will discover the power of automation and script-based operations to efficiently interact and update WebMaps in ArcGIS Online. Throughout this course, you will gain practical, hands-on experience in leveraging the ArcGIS API for Python to perform a wide range of WebMap tasks with ease.
We will dissect WebMaps for all that they are and by the end of this course you will be comfortable with manipulating the JSON, which is the behind the scenes configuration of a WebMap, to produce scripts for workflows where there is currently no API Python method, such as grouping layers.
All the code in one place
from arcgis.gis import GIS
## Access a GIS with the GIS Class
gis = GIS("home")
## Check if you are accessing a Portal
if gis.properties.isPortal:
## inside a Portal
print("Portal")
## Otherwise you are accessing ArcGIS Online
else:
## inside AGOL
print("AGOL")