What is the format for the search radius parameter in the Spatial Join in a python script?
I've tried a numeric value (5), 5 feet, and 5-feet.
You could write the parameter as "5 Feet".
Numeric Value with Units enclosed in Double Quotes.
Thanks Bruce and Jayanta for the reply. But, it does not appear to want to work using any value for the search radius. I'm only able to get the spatial join to run is with no value in the search radius.
May have to open a support ticket.
Snippet of the code used
outPoints = "PointsAlongRoutes"joinFeats = "MergedRoutes"outJoinFeat = "PointsJoinedToRoutes3"joinOp = "JOIN_ONE_TO_ONE"joinType = "KEEP_ALL"fieldMapping = ""matchOption = "INTERSECT"searchRadius = "10 Feet"distanceField = ""arcpy.SpatialJoin_analysis(outPoints, joinFeats, outJoinFeat, joinOp, joinType, fieldMapping, matchOption, searchRadius, distanceField)
Michael, try not supplying the field mapping, I'm not sure an empty string will work. You'll need to name parameters after switching from kwargs, like match_option="INTERSECT",search_radius='10 Feet')
Thanks for the heads up. I've changed the spatial join arguments as show below and it is still returning "ERROR 999998".
Any other ideas before I call support?
arcpy.SpatialJoin_analysis(target_features="C:/tmp/KMZ_Work/RouteData3/KML_Data3.gdb/PointsAlongRoutes", join_features="C:/tmp/KMZ_Work/RouteData3/KML_Data3.gdb/MergedRoutes", out_feature_class="C:/tmp/KMZ_Work/RouteData3/KML_Data3.gdb/PointsJoinedToRoutesTest2", join_operation="JOIN_ONE_TO_ONE", join_type="KEEP_ALL",match_option="INTERSECT", search_radius="5 Feet")
Hi, I'm stumped, the function looks right, it is possible there is something in your data that is causing an issue, maybe linear referencing related if thats what you are working with. Lets go with a support call. Sorry it isn't jumping out at me.
Yeah, if I remove the search_radius parameter, it runs fine. But I need the search radius.
Thanks for your time.
Another way of checking is to use ModelBuilder. Add the Tool to the model and define all the desired parameters. Then, export the Model to Python Script.
Hope it helps!!!
It works when using the spatial join tool in toolbox. I exported the snippet from the result and have used those parameters.
I will try it in a model.
Retrieving data ...