I have two polygon feature classes (buildings), one with attributes in green in the example below (building_sample.shp) and one with no attributes in red in the same example (building_sample_NA.shp).

enter image description here

I want the red buildings to take the attribute values of their closest green neighbor using arcpy.

Following the description of the SpatialJoin_analysis function, that should be easy but my code is not working:

ERROR 000210: Cannot create output

import arcpy
arcpy.env.workspace = "C:/DemoData/outputs"
arcpy.env.OverwriteOutput = True

arcpy.SpatialJoin_analysis (target_features = "building_sample_NA.shp",
                      join_features = "building_sample.shp",
                      out_feature_class = "building_completed",
                      join_operation = "JOIN_ONE_TO_ONE",
                      match_option = "CLOSEST")

Your error appears to be that you have made a mistake in capitalization.

Where you have:

arcpy.env.OverwriteOutput = True

it should be:

arcpy.env.overwriteOutput = True

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.