SubtypeGroupTable Issue with ArcGIS Online WebMap using the ArcGIS API for Python version 2.4.0

Table of Contents

Video

Introduction

The ArcGIS API for Python version 2.4.0 came in at ArcGIS pro 3.4 and there were some sweeping changes. Most notably, the removal of the WebMap class for the Map class. The way we interact with the WebMap changed significantly. In order to add or remove layers/tables from the WebMap we now create a Map object and access the content property which is a MapContent object and then we have methods such as add() and remove().

Automate ArcGIS Online WebMap 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 WebMap 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 WebMaps and the ArcGIS API for Python.

The Issue

When you use a method to alter a WebMap, you need to call the update() method on the Map object.

				
					map_obj.update()
				
			

However, if you have a table or tables in your WebMap, calling the update() method can cause all or one of the tables to become “corrupt”. The Table type switches to a SubtypeGroupTable rather than a Table.

Pre-update…

SubtypeGroupTable issue ArcGIS API for Python Version 2.4.0 without

Post-update…

SubtypeGroupTable issue ArcGIS API for Python 2.4.0 ArcGIS Online

You cannot access the table when you open the WebMap, when you go to the tables tab it will state that an error occurred loading this table.

SubtypeGroupTable WebMap issue ArcGIS Online ArcGIS API for Python 2.4.0

This has been to my detriment. Buuuut, there is a fix! You just need to manipulate the WebMap definition after your update() call – see the video above.

Note! This issue should be fixed in newer versions after 2.4.0. So hopefully you can skip over it. 

Here’s the code snippet…

				
					from arcgis.gis import GIS

agol = GIS("home")

wm_item = agol.content.get("WM_ITEM_ID")

wm_item_data = wm_item.get_data()

if "tables" in wm_item_data:
    for table in wm_item_data["tables"]:
        if "layerType" in table:
            del table["layerType"]

wm_item.update(item_properties={"text":wm_item_data})

################################################################################
print("\nSCRIPT COMPLETE")
				
			

Automate ArcGIS Online WebMap 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 WebMap 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 WebMaps and the ArcGIS API for Python.

Leave a Comment