gardta

Arcpy Spatial Join - Not joining all records with 'JOIN_ONE_TO_MANY', 'KEEP_ALL' option

Discussion created by gardta on Jul 11, 2017
Latest reply on Jul 13, 2017 by gardta

I am trying to perform a spatial join that will join all my join features (along with their attributes), within a specified distance, to my target features. Given the nature of the datasets, this should more than double the number of records in the target feature class (taking into account that not all of the join features are within the specified search radius). However, this join appears to rarely be functioning accurately. 

 

My target feature class consists of ~7000 records and when joined accurately via a 'JOIN_ONE_TO_MANY', 'KEEP_ALL'  spatial join contains ~16000 records. However, at least ~90% of the time the spatial join produces just under 8000 records. This has been frustrating, as this join is an integral part of a long script, and incorrect joins propagate into subsequent calculations. 

 

I am able to get the spatial join tool to run correctly using the same layers and options in ArcMap 10.4 or in ArcPro 1.4. Though, the python script seems to be producing unreliable results when ran in Visual Studio leveraging arcpy.SpatialJoin_analysis. 

 

The script was originally using Python 2 and ArcGIS 10.4. I switched to Python 3 (3.5.2) using a fresh Conda 3 download and the ArcPro Python package hoping that if the tool was buggy, this may fix it. No luck. Does anyone have any recommendations?

 

Here is the line of code for the spatial join:

 

arcpy.SpatialJoin_analysis ("SubLayer_Layer_2", "pp_trans_GUJoin_Layer_2", SubLayer_pp_trans_GUJoin_UniqueSubs, 'JOIN_ONE_TO_MANY', 'KEEP_ALL', "#", 'WITHIN_A_DISTANCE', .000002) 

Outcomes