1

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]

NoahMcDowall_2-1716296021790.png NoahMcDowall_2-1716296021790.png

3
  • 1
    Perhaps you'd be better off using a definition query to have only odd numbers in your export. The SQL will be either Attachment_id mod 2 = 1 or mod(Attachment_id,2) = 1. Commented Jun 4 at 4:22
  • 2
    Code should always be provided for coding questions as formatted text in the body of the Question. Images are not legible on all devices (especially black background), and require anyone who wants to help to retype all your code (not likely). Error messages should also be in clear text, so that anyone else with the same/similar issue can find you Question. Keep in mind that answers are provided to all who can find the Question -- Hiding your Question from search engines breaks this model (and may result in fewer volunteers to solve your issue).
    – Vince
    Commented Jun 4 at 4:59
  • Thanks for the advice, this is my first time making a stack overflow question Commented Jun 4 at 12:57

1 Answer 1

0

The workspace which you set the editor class to use must be the workspace that is holding the input feature class you are deleting from. From your screenshot it is clear you are pointing the editor to a completely different workspace.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.