Table of Contents
The Video
Introduction
Quite a simple but powerful workflow. Here, we are going to access an available Form item in ArcGIS Online that is publicly available and download the Survey123 package where we can then open up the Excel file to see how the same Form can be generated using Survey123 Connect.
This is very useful if you come across a survey that you like the look and feel of and are wondering how it was created. Perhaps there are some bespoke calculations or how the form displays that you can’t quite figure out how to implement. This workflow will help identify the solution.
Discover the power of automation and script-based operations to efficiently manage content in ArcGIS Online. Throughout this course, you will gain practical, hands-on experience with using the ArcGIS API for Python to perform a wide range of content management tasks with ease, such as creating Folders and Groups and managing content within them.
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.
## 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
agol = GIS("home")
## Access AGOL
agol = GIS(
url = "https://your_organisation.maps.arcgis.com/",
username = "Your_Username",
password = "Your_Password"
)
Get the Survey123 form as an Item Object
Check out the video on how to get the Form Item ID.
## get the form item as an Item object
form_item = agol.content.get("FORM_ITEM_ID")
Download
The Item object download() method will extract all we need to assess the Survey123 components.
## download the form zip file
form_item.download(
save_path = r"C:\Users\path\to\download\to"
)
Extract to Survey123 Folder
You Survey123 designs sit in here: C:\Users\*USERNAME*\ArcGIS\My Survey Designs
Extract the contents of the downloaded zip file to here.
Check out the video for more information on opening in Survey123 Connecvt.
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
You can find the entire code workflow below with links to important components in the documentation that were used.
from arcgis.gis import GIS
################################################################################
## API Reference Links:
## https://developers.arcgis.com/python/latest/api-reference/arcgis.gis.toc.html#gis
## https://developers.arcgis.com/python/latest/api-reference/arcgis.gis.toc.html#contentmanager
## https://developers.arcgis.com/python/latest/api-reference/arcgis.gis.toc.html#arcgis.gis.ContentManager.get
## https://developers.arcgis.com/python/latest/api-reference/arcgis.gis.toc.html#item
## https://developers.arcgis.com/python/latest/api-reference/arcgis.gis.toc.html#arcgis.gis.Item.download
##
################################################################################
################################################################################
## ACCESS ARCGIS ONLINE ########################################################
agol = GIS("home")
################################################################################
## GET FORM AS ITEM OBJECT #####################################################
## get the form item as an Item object
form_item = agol.content.get("FORM_ITEM_ID")
################################################################################
## DOWNLOAD ####################################################################
## download the form zip file
form_item.download(
save_path = r"C:\Users\path\to\download\to"
)
################################################################################
print("\nSCRIPT COMPLETE")