Select to view content in your preferred language

ArcGIS API for Python version 2.4.0 WebMap Table SubtypeGroupTable Issue Workaround

316
1
04-02-2025 09:54 AM
Clubdebambos
MVP Regular Contributor
4 1 316

 

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

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

Clubdebambos_3-1743612582831.png

 

Post-update...

Clubdebambos_2-1743612478208.png

 

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.

 

Clubdebambos_4-1743612788734.png

 

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

 

1 Comment
Contributors
About the Author
GIS Consultant with extensive experience utilising skills for GIS project management, quality map production, data management, geospatial analysis, standardisation, and workflow automation across a range of industries such as agriculture, oil & gas, telecommunications and engineering. Going beyond map production there is a passion for the technologies behind GIS, the databases, the programming languages, the analysis and statistical output, and continued professional development associated with GIS. You will mainly find me contributing in the Python and ArcGIS API for Python Communities.