# 1. Import arcpy module import arcpy, os, sys, datetime from arcpy import env # 2. Set geoprocessing environment scratch = arcpy.env.scratchWorkspace arcpy.env.scratchWorkspace = r"E:\geoprocessing\Building\Outputworkspace" arcpy.env.overwriteOutput = True # 3. Specify Date and Time now = datetime.datetime.now() # 4. Input Parameters Initials = arcpy.GetParameterAsText(0) InspDate = arcpy.GetParameterAsText(1) if InspDate == "": InspDate = now.strftime("%m-%d-%y") #This will return today's date. arcpy.AddMessage("Searching for scheduled inspections...") Xpression = """ "INSPECTOR" = \'%s\' AND "SCHEDULED_DATE" = \'%s\' """ % (Initials, InspDate) # 5. Local variables: sde_sdegis_VCOE_CRWINSPECTIONLOG = r"e:\connections\AGSGIS_TO_SDEGIS_COE.sde\\sde.sdegis.VCOE_CRWINSPECTIONLOG" CRWInspectionLog = "CRWInspectionLog" CRWInspectionLogCopyRows = os.path.join(scratch,CRWInspectionLogCopyRows.dbf) AddressesWithBldgno = r"e:\locators\\AddressesWithBldgNo" ScheduledInspections = os.path.join(ScheduledInspections.shp) # 6. Make Query Table and Copy Rows if Result is greater than 0 arcpy.AddMessage("Selecting scheduled inspections...") arcpy.MakeQueryTable_management(sde_sdegis_VCOE_CRWINSPECTIONLOG, CRWInspectionLog, "NO_KEY_FIELD", "", "", Xpression) result = int(arcpy.GetCount_management(CRWInspectionLog).getOutput(0)) arcpy.AddMessage("Inspections Found: " + str(result)) if result == 0: arcpy.AddWarning("Process terminated."); sys.exit() else: arcpy.CopyRows_management(CRWInspectionLog, CRWInspectionLogCopyRows, "") del CRWInspectionLog # 7. Geocode Inspections arcpy.AddMessage("Geocoding inspections, please wait...") arcpy.GeocodeAddresses_geocoding(CRWInspectionLogCopyRows, AddressesWithBldgno, Street SITE_ADDR VISIBLE NONE;City <None> VISIBLE NONE, ScheduledInspections, "STATIC") result1 = int(arcpy.GetCount_management(ScheduledInspections).getOutput(0)) arcpy.AddMessage("Inspections Geocoded: " + str(result1)) if result1 < result: arcpy.AddWarning("Not all inspections were mapped.") else: arcpy.AddMessage("All inspections mapped.") # 8. Scheduled Inspections Output arcpy.SetParameterAsText(2, ScheduledInspections)
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.