I am trying to populate a grid with the number of features in each grid cell. I've gotten this script to work with a subset of the data, but when I try to run it on the full (52,000+) cell feature class, it freezes when doing the Field Calculation and won't progress past it. I want to run it outside of Arc so it processes faster than the 20 minutes it took to run inside Arc.
I'm using Identity to split these features by the grid cells, so I get an accurate count, then spatial joining that to the Grid, then joining the FID from the spatial join to the original grid and field calculating the Join Count over. This is done for several feature classes, so I need it to calculate into the original Grid FC.
Additionally can arcpy do feature layer outputs like running the script inside Arc?
Whenever I have my input as "Input" I get an error 000210 cannot create output.
arcpy.MakeFeatureLayer_management(Grid, "Grid_Lyr")
Feature_Split = "C:\Users\Testing.gdb\Feature_Split"
Feature_Join = "C:\Users\Testing.gdb\Feature_Join"
print "Counting Features"
arcpy.Identity_analysis(Ways, Grid, Feature_Split)
print "Identity Analysis Done"
arcpy.SpatialJoin_analysis("Grid_Lyr", Feature_Split, Feature_Join , "JOIN_ONE_TO_ONE", "KEEP_ALL", "", "CONTAINS")
print "Spatial Join Done"
arcpy.AddJoin_management("Grid_Lyr", "OID", Feature_Join, "TARGET_FID", "KEEP_ALL")
print "Join Added"
arcpy.CalculateField_management("Grid_Lyr", "Feature_Count", "!Feature_Join.Join_Count!", "PYTHON_9.3", "")
arcpy.RemoveJoin_management ("Grid_Lyr")
print "Fields Calculated"