I have the following ArcPy code, which I need to run on very large datasets. Are there any suggestions for making it run faster? It's taking upwards of an hour and half to run the section I posted below, and there are 5 such sections within the entire code.
if fhz_chk == "true": arcpy.analysis.Intersect([FHZ,analysislyr],"FHZ_Int","ALL","","INPUT") arcpy.analysis.Intersect([FHB,analysislyr],"FHB_Int","ALL","","INPUT") arcpy.management.CalculateField("FHZ_Int","FHZ", 1) arcpy.management.CalculateField("FHB_Int","FHB", 1) arcpy.management.Merge(["FHZ_Int","FHB_Int"],fhz_class) arcpy.management.CalculateField( fhz_class, "FHZ_Sev", "iif($feature.FHZ == '1', 'Severe', iif($feature.FHB == '1', 'High','None'))", "ARCADE" ) arcpy.management.CalculateField( fhz_class, "FHZ_Sev_Number", f"iif($feature.FHZ_Sev == 'Severe', {fhz_sev_val}, " f"iif($feature.FHZ_Sev == 'High', {fhz_high_val}, " f"iif($feature.FHZ_Sev == 'Moderate', {fhz_mod_val}, {fhz_low_val})))", "ARCADE" ) fhzflds = arcpy.ListFields(fhz_class) for field in fhzflds: if field.name == "Priority": arcpy.AddMessage("Priority set by rdwy") else: arcpy.management.CalculateField(fhz_class,"Priority",f"{priority_value}","ARCADE") arcpy.management.CalculateField( in_table=fhz_class, field = f"FHZ_Impact_{analysislyr}", expression = "safe_float(!FHZ_Sev_Number!) * safe_float(!Priority!)", expression_type = "PYTHON3", code_block = """ def safe_float(val): return float(val) if val is not None else 0 """, field_type = "DOUBLE" ) FHZ_Impact_Total = f"FHZ_Impact_{analysislyr}" else: arcpy.AddMessage("FHZ not analyzed as a hazard") FHZ_Impact_Total = 0 The run time isn't horrid on smaller datasets, but its unusable on the larger ones I need to perform the analysis on.
importstatements. We don't know whatFHZ,analysislyr, and a bunch of other symbols describe. It's unclear what business Use Case you seek to address, and how this code might accomplish that. We are told that elapsed time exceeds 5400 seconds, but we're ignorant of the nature of the input records nor how many were offered. Please take the tour. \$\endgroup\$