A few months ago, I set up a Collector app for a colleague who went into the field for two weeks. The web map contained 5 feature layers of assets. Once he reached the asset in the field, he would select the corresponding point, update attributes and attach at least one photo. It was basic verification work.
The amount of issues I ran into once he was out in the field was huge. I’m saving all my good stuff for a later series of posts I will write on mobile data capture, but let’s just say Collector has some kinks to work out. On the plus side, I had to write several scripts to sort out the issues, and this was one of them.
The photos are stored in separate folders per feature layer, per named feature. For example, the “Mini Substation” folder has a subfolder called “Minisub 1”, which has 5 photos named Photo1.jpg, Photo2.jpg etc. This is why I could not use the Generate Attachment Match Table tool.
In Line 22, I’ve chosen to create the table in memory first, for faster read/write access. In Line 25, I add fields to this new table (in future, I will be doing this using ExtendTable() instead).
In Line 34, I insert a new row into the table for each photo, containing the photo’s root folder as the ID (named feature), and the path to the individual photo. The table is copied to disk in Line 37, and the attachments are added to the feature class in Line 41.