I am using Collector on a project that relies heavily on photo attachments. Viewing the photographs of collected data points in ArcGIS Online is working well, but I also want to share these photo attachments in other formats.
Specifically, I want to export an attribute table to a spreadsheet with photo attachments viewable on the spreadsheet (or create a report from ArcMap with these photo attachments). I also would like to be able to share feature classes in ArcMap that include photograph attachments. However, I haven’t figured out how to achieve either.
When I export ArcGIS Online feature classes to ArcGIS for desktop, the attachments are viewable in the attachment manager for each point. If I try to export the feature class to share with another party, however, the attachments are lost. Similarly, when I export the attribute table to a spreadsheet the photos aren’t viewable.
So I have two questions:
Any help or guidance is appreciated. Thank you!
Thanks Zac,
I should have mentioned that I am trying to do this on a computer with no ESRI sodtware installed only python. Jake's looks like it should be able to do it. I am just trying to get that script working.
Regards
Hi Jake and Stephan,
Thanks for the code snippet, Jake - it works when I have exactly two photos per one pint. But if I have zero to three or more photos, I get the same error that Stephan gets = "IndexError: list index out of range"... How can I modify the code to ignore any points that don't have any photos or only have one photo? I'm aware that I'd need to add a third Image column to hold additional photos, but what else am I missing... The error appears at the line " row[1] = path + os.sep + dict[key][1]". Thanks much!
...
dict = {}
with arcpy.da.SearchCursor(fc, ["GlobalID"]) as cursor:
for row in cursor:
OID = row[0]
dict.setdefault(OID, [])
with arcpy.da.SearchCursor(table, ["ATT_NAME"], "REL_GLOBALID = '" + str(OID) + "'") as cursor2:
for row2 in cursor2:
dict[row[0]].append(row2[0])
del cursor, cursor2
for key in dict:
with arcpy.da.UpdateCursor(fc, ["Image1", "Image2"], "GlobalID = '" + str(key) + "'") as cursor:
for row in cursor:
row[0] = path + os.sep + dict[key][0]
row[1] = path + os.sep + dict[key][1]
cursor.updateRow(row)
del cursor
Try using a try/except statement. I haven't tested it, but this should bypass the error:
for key in dict: with arcpy.da.UpdateCursor(fc, ["Image1", "Image2"], "GlobalID = '" + str(key) + "'") as cursor: for row in cursor: try: row[0] = path + os.sep + dict[key][0] row[1] = path + os.sep + dict[key][1] except: pass cursor.updateRow(row)
Now I'm getting this error:
Traceback (most recent call last):
File "C:\DATA\Projects\Sign_Inventory\LameDeerRAB\LameDeerTrip2\export_LameDeer2_step2_REV.py", line 44, in <module>
for row in cursor:
RuntimeError: workspace already in transaction mode
I added in code to start and stop an edit session so I didn't have to delete the relationship, and that has worked in previous settings where I had exactly two photos per one point...
EDIT - I figured out that this error refers to the way I started my edit operation. I changed the parameters for the "edit.startEditing" command to "(False, False)" and the try/except statement worked!!! I had previously set them to False, True. I'm working with a file geodatabase and only one editing operation, so once I changed it, it ran successfully. Thanks very much for your help and your very prompt response!
This seems painful... as our data gets updated daily and we want to create daily reports about the features collected including pictures...
Any suggestions on how to use this directly from the SDE?
Thanks!
Jessica
What format (i.e. PDF, Excel) are you exporting your report to?
Hoping for PDF – struggling with whole Collector --> ArcMap --> PDF workflow
I am also looking into being able to create a .pdf Report that would allow me to embed any attachments (.jpgs) associated with a particular record.
Hi Jake,
Do you know if there is a way to copy/paste a subset of records from a feature class and still be able to bring over the corresponding attachments?
Thank you!
Alina
I figured out how to get the attachments to show up in a report created through ArcGIS:
The only thing I still have to figure out is how to get all attachments associated with one record to show up as one report item.