GP tool to clear geoprocessing history from feature class

309
5
03-22-2024 01:13 PM
Status: Already Offered
Labels (1)
Bud
by
Notable Contributor

ArcGIS Pro 2.9.12; Oracle 18c 10.7.1 EGDB:

I have cases where I need to clear the geoprocessing history of a feature class in the geodatabase.

For example, in 2.9.12, there is an issue where Route Event Layers are slow to the point they're unusable, due to extensive geoprocessing history in the FC. Removing the geoprocessing history in a FGDB copy via XML solves the issue, proving that the geoprocessing history is the problem.

It would be ideal to have a GP tool to remove the geoprocessing history from existing geodatabase feature classes, rather than manually fiddling with XML. 

Related: Don't track GP tools like Add Relate in FC geoprocessing history

5 Comments
MErikReedAugusta

I knew GP History could be saved in MXD/APRX files and cause bloat (which is why I regularly clean long-running projects), but I had no idea it could be stored in a Feature Class.  Shocking!

DrewFlater
Status changed to: Already Offered

Automated metadata management in ArcGIS Pro uses the arcpy.metadata module, rather than a geoprocessing toolbox/toolset. 

https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/what-is-the-metadata-module.htm

To remove geoprocessing history/lineage from a dataset's metadata:

md = arcpy.metadata.Metadata(path_to_dataset)
md.deleteContent('GPHISTORY')
md.save()

 

And to make it so when you run tools it is not saved in the metadata, use this Geoprocessing Option

 

Bud
by

@DrewFlater Thanks. That helps.

With that said, I think this idea is still valid. My preference is to always use OOTB tools, rather than ask users (non-coders) to use Python scripts. 

Saying "it can be done with Python" applies to most existing GP tools. I don't see how this case is different. Why not allow us to request a GP tool?

DrewFlater

Hi, 

The Metadata editor in Pro 3.3 includes an interactive table that lists the Geoprocessing History/lineage stored in the dataset's metadata, which you can delete or export. 

DrewFlater_0-1711409991496.png

So you can choose to use the interactive experience, or for automation use the arcpy.metadata module. There isn't really a position for a geoprocessing tool given these alternatives.  

Bud
by

A note about the path_to_dataset in Python from @DrewFlater :

...Python uses the \ backslash character as an escape character, so you need to either use double backslashes, use forward slashes, or put an r at the front of the string to indicate raw string.