My question mainly centers around how to export a set of images on ArcGIS Pro.
What I am trying to do:
I have a Survey123 dataset from which I need to extract quadrat sites ( images attached to each point), according to the corresponding numbers assigned to them ( site number). I need each image to be correspond to each site number, since each site includes numerical data on percent coverage to go with each image stored in a geopoint. Here's the process I intend to follow.
Extracting Data from AGOL:
I extracted the data from ArcGIS Online (AGOL) to avoid complications with permissions and access issues associated with feature services. To do this, I went into the Survey in Survey123 and exported the data as a fileGeoDatabase
Separate the evens from the odd:
I only need data from the odd points. I used the following script which I show below, to get rid of all the even points. I ran this through a custom analysis too, which I am attaching an image of below.
Extracting Images from File Geodatabase:
After cleaning the data in the file geodatabase, I needed to extract the images. I used ArcGIS Pro and followed the method described in this ESRI: How To: Batch Export Attachments from a Feature Class in ArcGIS Pro.
Problem:
My problem is in the detaching evens section I keep on encountering the error message when I try to run it as an analysis tool that:
Does anyone have a suggestion on how to solve this or a generally better approach?
# Input parameters
workspace = arcpy.GetParameterAsText(0) # Workspace (e.g.,geodatabase, folder, etc.)
input_fc = arcpy.GetParameterAsText(1) # Input feature class
attachment_id_field = arcpy.GetParameterAsText(2)
arcpy.env.workspace = workspace # Specify the workspace
# Start an edit session
edit = arcpy.da.Editor(workspace)
edit.startEditing(False, True)
edit.startOperation()
# Update cursor to delete rows with even Attachment IDs
with arcpy.da.UpdateCursor(input_fc, ['OID@', attachment_id_field]) as cursor:
for row in cursor:
oid, attachment_id = row
if attachment_id % 2 == 0: # Check if Attachment ID is even
cursor.deleteRow()
edit.stopOperation()
edit.stopEditing(True) # The True argument saves the changes
arcpy.AddMessage("Rows with even Attachment IDs deleted.")
Error message
Traceback (most recent call last):
File "C:\Users\mcdow\Documents\New_exporter.py", line 20, in
<module>
for row in cursor:
RuntimeError: Objects in this class cannot be updated outside
an edit session [survey]