0

I'm getting an error when excecuting a script thats suppose to spatial join two point layers. Code says:

Error 000561 Invalid parameters

But, I'm pretty certain that they are correct.

Can anyone tell me what might be wrong with the code?

I've read that it might be because multiple points might be withing distance of parameters of one point so that it requires fieldmapping. But I have not figured out how I'm suppose to do this.

import arcpy, sys, string, os, datetime, copy

# Local Path
sti_endring = 
r"Y:\N50_Kartdata\Arbeidsfiler\Kontroll\Script\N250_Kontroll\Dataopp
datering\Endringsdata\finn_endring.gdb\\"

# Local variables:
N250_HoydetallObjkoord = sti_endring + "N250_HoydetallObjkoord"
N50_HoydetallObjkoord = sti_endring + "N50_HoydetallObjkoord"
HoydetallObjkoord_joined = sti_endring + "HoydetallObjkoord_joined"

# Process: Spatial Join
target_features = N250_HoydetallObjkoord
join_features = N50_HoydetallObjkoord
out_feature_class = HoydetallObjkoord_joined
arcpy.SpatialJoin_analysis(target_features, join_features, 
out_feature_class, "JOIN_ONE_TO_MANY", "KEEP_ALL", "INTERSECT", "350 
Meters", "")
  • What are your N250_HoydetallObjkoord, N50_HoydetallObjkoord and HoydetallObjkoord_joined variables set to? – PolyGeo Aug 1 '17 at 9:22
  • They are set equal to original name, so no change in variable. – proxmo Aug 1 '17 at 9:25
  • What original name? In any event where you set them should be part of the code snippet that you present. – PolyGeo Aug 1 '17 at 9:26
  • You need an r in front of "Y:\ to deal with those single backslashes as a raw string. – PolyGeo Aug 1 '17 at 9:37
  • The "r" didn't transfer over when i copied the code, I've added it now. – proxmo Aug 1 '17 at 9:58
3

I would avoid mentionning the distance_field_name parameter, as it is not applicable with the match_option parameter.

Also, and more importantly, it seems you are skipping the field_mapping parameter (reference syntax is available here). Either add it, stating it is null ('#') or specify what the subsequent parameters are. These two options look like this:

Either

arcpy.SpatialJoin_analysis(target_features, join_features, 
out_feature_class, "JOIN_ONE_TO_MANY", "KEEP_ALL", "#", "INTERSECT", "350 
Meters")

Or:

arcpy.SpatialJoin_analysis(target_features, join_features, 
out_feature_class, "JOIN_ONE_TO_MANY", "KEEP_ALL", match_option="INTERSECT", search_radius="350 Meters")
  • Thanks, that got the code working. I didn't think i needed to add field_mapping paramater if i did not intend to use it. – proxmo Aug 1 '17 at 10:32

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.