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().

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.

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")
				
			

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.

Leave a Comment

Your email address will not be published. Required fields are marked *