How to manage Collector app photos and features without Standard license

1029
3
08-24-2017 06:31 AM
WolfgangWolter
New Contributor II

I have an issue in managing my Collector map once photo attachments have been made. In my map there are number of features with attachments enabled and stored, and the photos can be viewed in the online map no problem. However, since I do not have the Standard license, I cannot manipulate the downloaded geodatabase version of those features.

The features with attachments enabled create the "__ATTACH" and "__ATTACHREL" , which cannot be deleted in the Desktop application due to licensing. However, I believe these are also locking the geodatabase from edits, so I am unable to change the features for future work. Is there a good way to (a) view or download the photos for each point, and (b) allow editing other fields in the geodatabase, without losing the current data? Thanks.

https://community.esri.com/groups/geodatabase?sr=search&searchId=ce685c00-0bc0-43fb-bec2-79939c13445...https://community.esri.com/community/gis/applications/collector-for-arcgis?sr=search&searchId=d6ca3e...

Tags (3)
0 Kudos
3 Replies
MitchHolley1
MVP Regular Contributor

I have found a script online that downloads attachments.  Hopefully this will help.

import arcpy
import os

inTable = r'...path to _ATTACH table...'
fileLocation = r'...path to output folder location to save attachments...'

files = []

with arcpy.da.SearchCursor(inTable, ['DATA','REL_GLOBALID']) as cursor:
    for item in cursor:
        try:
            attachment = item[0]
            filename = str(item[1]) + '_1.jpg' #change file extension if not .jpg
            if filename not in files:
                files.append(filename)
                open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes())
            else:
                arcpy.AddMessage(row[1] + " already exists.")
                #or you could rename the file here and save it like above
        except Exception, E:
            arcpy.AddMessage(E.message)
            continue
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
WolfgangWolter
New Contributor II

Thanks Mitch, that is an excellent starting point. I will see if I can also scrub out the lat/long coordinates and include them in the photo properties, then this will work perfectly. Thanks again.

0 Kudos
WolfgangWolter
New Contributor II

Here is a quick update that saves all the attachments, alluded to in the original script you found. I set this up to 10 attachments as a failsafe but can easily change to any number of attachments (or no limit).

import arcpy
import os

inTable = r'...path to _ATTACH table...'
fileLocation = r'...path to output folder location to save attachments...'

files = []

with arcpy.da.SearchCursor(inTable, ['DATA','REL_GLOBALID']) as cursor:
    for item in cursor:
        try:
            attachment = item[0]
            filename = str(item[1]) + '_1.jpg' #change file extension if not .jpg
            if filename not in files:
                files.append(filename)
                open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes())

            else:
                #arcpy.AddMessage(row[1] + " already exists.")
                #or you could rename the file here and save it like above
                # # quick script addition to save all attachments up to 10 files
                i = 2
                while True:
                    ff = str(item[1]) + '_' + str(i) + '.jpg'
                    if ff not in files:
                        files.append(ff)
                        open(fileLocation + os.sep + ff, 'wb').write(attachment.tobytes())
                        break
                    if i > 10:
                        arcpy.AddMessage(row[1] + " has greater than 10 files, not extracted properly.")
                        break
                    i = i +1

        except Exception, E:
            arcpy.AddMessage(E.message)
            print E.message
            continue
0 Kudos