def main(): inFGDB = arcpy.GetParameterAsText(0) outLocation = arcpy.GetParameterAsText(1) photoDir = arcpy.GetParameterAsText(2) deleteDirectory = False if photoDir == "": photoDir = tempfile.mkdtemp() deleteDirectory = True attachmentTables = getAttachmentTables(inFGDB) outFCList = [] for table in attachmentTables: tablename = table.replace('__ATTACH', '') # tablename = tablename.strip('_') tabledir = os.path.join(photoDir, tablename) os.mkdir(tabledir) exportAttachments(inFGDB, table, tabledir) photo_Prefix = tablename photoTable = photo_Prefix + "_PHOTOS" photosFC = os.path.join(outLocation, photoTable) arcpy.GeoTaggedPhotosToPoints_management( tabledir, photosFC, Add_Photos_As_Attachments="ADD_ATTACHMENTS") outFCList.append(photosFC) outFGDB = arcpy.SetParameterAsText(3, outLocation) outFCs = arcpy.SetParameterAsText(4, ';'.join(outFCList)) if deleteDirectory == True: shutil.rmtree(photoDir, ignore_errors=True) return
def photo2env(rootdir, bufferDist): """ Creates a point layer from geotagged photos, buffers to set distance, creates polygon to encompass all buffered areas. Assumes directory structure of rootdir\refID\sensor\output... """ for dir in os.listdir(rootdir): refID = rootdir + "\\" + dir for subdir in os.listdir(refID): inFolder = refID + "\\" + subdir outFeatures = refID + "\\points2" if subdir == "Sequoia": print(inFolder + " Processing") arcpy.GeoTaggedPhotosToPoints_management(inFolder, outFeatures) arcpy.Buffer_analysis(outFeatures + ".shp", outFeatures + "_buff2", bufferDist) arcpy.MinimumBoundingGeometry_management(outFeatures + "_buff2.shp", outFeatures + "_ENV2", "ENVELOPE", "ALL")
"PRS 1992 Philippines Zone III") arcpy.env.geographicTransformations = "PRS_1992_To_WGS_1984_1" # 0. Define parameters workSpace = arcpy.GetParameterAsText(0) inFolder = arcpy.GetParameterAsText( 1) # Choose a directory where the excel master list is saved. originalFeature = arcpy.GetParameterAsText(2) # 1. convert geotagged photos to points outFeatures = "photo_points" badPhotoist = "photos_noGPS" photoOption = "ONLY_GEOTAGGED" attachmentsOption = "NO_ATTACHMENTS" photoLayer = arcpy.GeoTaggedPhotosToPoints_management(inFolder, outFeatures, badPhotoist, photoOption, attachmentsOption) # 2. Add field to the poin feature layer (i.e., Description, Date, ImageURL, and Title) addFields = ["Description", "ImageURL", "Title"] for field in addFields: arcpy.AddField_management(photoLayer, field, "TEXT", "", "", "", field, "NULLABLE", "") # 3. Enter information in the added fields ## When a point layer is created, it automatically adds Name and DateTime ## so we can obtain photo names uing 'Name' ### Use Calculate Field #### Add information to 'Title' field_Title = "Title"
arcpy.AddMessage("Step 1: Loading input parameters") if str (AngleField) == 'true': AngleField = 'Direction' else: AngleField = '' if CameraInput == 'Associate Photo with Parcel': # ______________________________________________________________________________# # # Convert Passenger Photos to Points #_______________________________________________________________________________# PhotoFeatureClass = Geodatabase + "\\PointAttachmentsTemp" #"""{}\\PointAttachmentsTemp""".format(Geodatabase) arcpy.GeoTaggedPhotosToPoints_management(PassengerPhotos, PhotoFeatureClass, invalidPhotosTablePassenger, "ONLY_GEOTAGGED", "NO_ATTACHMENTS") #______________________________________________________________________________# # # If Name is used for ParcelPIN make adjustments #______________________________________________________________________________# if ParcelPIN is "Name": arcpy.AlterField_management(PhotoFeatureClass, ParcelPIN, "Image_Name") else: pass SR = arcpy.Describe(Parcels) SRHelper = SR.spatialReference PhotoFeatureClass2 = Geodatabase + "\\PointAttachments"
#Set Local Variables rawfolder1 = r"W:\Operations\Holstein\RawData1\BLK_12_18_19_20\BLK12\DCIM\IX-02-71420_0045\thm" #rawfolder2 = r"W:\Operations\Holstein\RawData1\BLK_12_18_19_20\BLK18\BLK18\BLK18\DCIM\IX-02-71420_0046\thm" #rawfolder3 = r"W:\Operations\Holstein\RawData1\BLK_12_18_19_20\BLK18\BLK18\BLK18\DCIM\IX-02-71420_0047\thm" #rawfolder4 = r"W:\Operations\Holstein\RawData1\BLK_12_18_19_20\BLK19\BLK 19\BLK 19\DCIM\IX-02-71420_0042\thm" #rawfolder5 = r"W:\Operations\Holstein\RawData1\BLK_12_18_19_20\BLK20\BLK 20.1\BLK 20\DCIM\IX-02-71420_0039\thm" #name your output feature layers savedir1 = geodatabase + "/thm_45" #savedir2 = geodatabase + "/thm_46" #savedir3 = geodatabase + "/thm_47" #savedir4 = geodatabase + "/thm_42" #savedir5 = geodatabase + "/thm_39" Photos2Points1 = arcpy.GeoTaggedPhotosToPoints_management(rawfolder1, savedir1) #Photos2Points2 = arcpy.GeoTaggedPhotosToPoints_management(rawfolder2, savedir2) #Photos2Points3 = arcpy.GeoTaggedPhotosToPoints_management(rawfolder3, savedir3) #Photos2Points4 = arcpy.GeoTaggedPhotosToPoints_management(rawfolder4, savedir4) #Photos2Points5 = arcpy.GeoTaggedPhotosToPoints_management(rawfolder5, savedir5) print("All photos converted into points & saved to {0}".format(geodatabase)) print("Merging points...") MergeOutput = geodatabase + "/thm_ALL" arcpy.Merge_management([ Photos2Points1, Photos2Points2, Photos2Points3, Photos2Points4, Photos2Points5 ], MergeOutput, "", "ADD_SOURCE_INFO")