In answers and comments to Select points within a polygon and update attributes I think it is being suggested that Spatial Join (Analysis) and/or Near (Analysis) may be faster than Intersect (Analysis) for performing a point in polygon overlay to transfer polygon attributes onto the points that intersect them.

This surprised me because I have always expected that Intersect might be a bit quicker than Spatial Join, and I think it would be quite a lot quicker than Near. Unfortunately, I do not have an Advanced level license of ArcGIS for Desktop so I cannot performance test Near.

Does anyone have a reproducible test that indicates Near and/or Spatial Join being faster than Intersect?

I am going to provide as an answer my test on Intersect vs Spatial Join where I create a 10x10 fishnet of polygons and a 100x100 fishnet of points covering the same extent (0,0,10,10) and then perform a vanilla Intersect and a vanilla Spatial Join (INTERSECT) of the two.


My quick testing, using ArcGIS 10.2.2 for Desktop on Windows 7 SP1, indicates that Intersect is faster than Spatial Join.

This test, run from IDLE:

import arcpy,time

if not arcpy.Exists(r"C:\temp\test.gdb"):
if arcpy.Exists(r"C:\temp\test.gdb\fnPoly100"):
if arcpy.Exists(r"C:\temp\test.gdb\fnPoly10000"):
if arcpy.Exists(r"C:\temp\test.gdb\fnPoint10000"):
arcpy.CreateFishnet_management("C:/temp/test.gdb/fnPoly100","0 0","0 1","1","1","10","10","#","NO_LABELS","#","POLYGON")
arcpy.CreateFishnet_management("C:/temp/test.gdb/fnPoly10000","0 0","0 1","0.1","0.1","100","100","#","LABELS","#","POLYGON")

if arcpy.Exists(r"C:\temp\test.gdb\SpatialJoinResult"):
start = time.clock()
                           """Shape_Length "Shape_Length" false true true 8 Double 0 0 ,First,#,C:/temp/test.gdb/fnPoly100,Shape_Length,-1,-1;Shape_Area "Shape_Area" false true true 8 Double 0 0 ,First,#,C:/temp/test.gdb/fnPoly100,Shape_Area,-1,-1""",
elapsed = (time.clock() - start)
print("Spatial Join took " + str(elapsed) + " seconds")

if arcpy.Exists(r"C:\temp\test.gdb\IntersectResult"):
start = time.clock()
arcpy.Intersect_analysis("C:/temp/test.gdb/fnPoint10000 #;C:/temp/test.gdb/fnPoly100 #",
elapsed = (time.clock() - start)
print("Intersect took " + str(elapsed) + " seconds")

yielded these results:

Spatial Join took 3.13998451416 seconds

Intersect took 2.3185308145 seconds

I ran my test with the Intersect first a few times, and then the Spatial Join first a few times, and Intersect was always the winner on this data.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.