2

I am seeking some ArcPy/Python help. I use the mobile app GIS Pro to collect data in the field, which allows me to export shapefiles containing a field called Photos, containing a list of names of photos associated with each feature. The list appears like this:

enter image description here

I am trying to create a tool that will

  1. Import the shapefile into a project geodatabase
  2. Add the features from the shapefile to a "master feature class"
  3. Update an attachment match table to include the photos associated with the new features
  4. Add the new attachments

I am struggling with step 3. There needs to be a new entry in the match table for each photograph. The match table contains the fields REL_OBJECTID & ATT_NAME. The REL_OBJECTID needs to coincide with the OID assigned to the feature after it has been merged into the "master feature class".

1

Forget about fields in attachment table, Arcgis add attachments tool will populate them for you. Based on field names I assume you are using arcgis. Create new table with 2 fields: name - text long enough to store "observatin 1" etc, path - text long enough to store folder name where you saved your pictures + photo name.

InsC=arcpy.da.InserCursor (abovetable, ("name","path"))

with da.searchcursor (shapefile, ("name","photos")) as cursor:

for name, alist in cursor:

  alist = alist.split (",")

  for photo in alist:

     R = (name, os.path.join (folderWpictures,photo))

     InsC.insertRow(R)

Use table as match table in add attacments tool to your fgdb feature class.

Caution: fix rotation of your pictures, before attaching them. I use infraview batch convert. It understands rotation of pictures taken by mobile device

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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