0

I'm trying to projects a feature with attachments from one coordinate system to another without loosing the attachments.

I'm using the GeoTagged Photos To Points function to create a point feature class which also contains the photos as attachments.

Unfortunately this function does not provide an option to reproject the output feature class. And if I use the project_management function, I lose the attachments.

Minimal example:

import arcpy
arcpy.env.maintainAttachments = True 
# maintainAttachments work for the following function:
# - Append
# - Copy
# - Copy Features
# - Copy Rows
# - Feature Class To Feature Class
# - Merge
# - Table To Table
arcpy.GeoTaggedPhotosToPoints_management(folder, photo_gps, "", "ALL_PHOTOS", "ADD_ATTACHMENTS")
arcpy.Project_management(photo_gps, photo_gps_proj, out_coordinate_system)

But unfortunately photo_gps_proj do not contains the attachments !

How can I project photo_gps and keep the attachments ?

  • That tool does support the outputcoordinatesystem environment setting, although I would suggest also setting the transformation you want in the environment too. – mkennedy Feb 21 at 20:30
1

I've found a solution by myself:

I reproject my original feature (oFC) to obtain the projected feature (pFC), then I change the projection system of oFC and I copy the shape of pFC:

# Reprojection
sr = arcpy.SpatialReference(2056) #define the new projection
arcpy.Project_management (featurename, featurename+'_proj', sr,'CH1903+_To_WGS_1984_1') # create the projected feature
arcpy.DefineProjection_management(featurename, sr) #change the projection of the original feature

# Replace the shape of oFC with the shape of pFC
edit = arcpy.da.Editor(arcpy.env.workspace)  
edit.startEditing(False, True)  
edit.startOperation()  

with arcpy.da.SearchCursor(featurename+'_proj', ["GUID", "SHAPE@"]) as cursor1:
    for row1 in cursor1:
        with arcpy.da.UpdateCursor(featurename, ["GUID", "SHAPE@"]) as cursor2:
            for row2 in cursor2:
                if row1[0] == row2[0]:
                    row2[1] = row1[1]
                    cursor2.updateRow(row2)

edit.stopEditing(True)

arcpy.RecalculateFeatureClassExtent_management(featurename)

# Delete the unecessary feature:
if arcpy.Exists(featurename+'_proj'):
    arcpy.Delete_management(featurename+'_proj')

Work like a charm.

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.