I´ve got a point feature class with some 7.000.000 points and I´m trying to check if any of these points is simply intersected by several polygon feature classes using 'for' loop and 'arcpy.SelectLayerByLocation'. Polygon feature classes contain just 1 polygon feature each and are saved in a folder as shapefiles.
I can create a feature layer from points and then use Select Layer by Location with "INTERSECT" parameter but my problem is that the polygon feature can be intersected by e.g. 700.000 points and the process of selection takes ages.
My question is: is there any way to break the Select Layer by Location process after it finds a first point that is intersected by the polygon? Or do I have to wait until the whole process finishes? The code is simple:
# Create a layer from feature class with 7.000.000 points arcpy.MakeFeatureLayer_management(pointFC, "point_lyr") # Builds a list of polygon feature classes within a workspace fcs = arcpy.ListFeatureClasses("", "polygon") for polygon in fcs: arcpy.SelectLayerByLocation_management("point_lyr", "INTERSECT", polygon, "", "NEW_SELECTION") # And now instead of: # Count selected points after the process ends and do something if condition is met points_count = int(arcpy.GetCount_management("point_lyr").getOutput(0)) if points_count != 0: something # I´d rather have if a point intersects the polygon for the first time: tell me that this happened, then break this loop and start another polygon loop
Is it possible to break a running arcpy process?
Running on Win7, ArcGIS for Desktop Basic 10.1 + Python 2.7